Skip to content

Conversation

moking
Copy link

@moking moking commented Jan 19, 2017

No description provided.

pjvds and others added 30 commits October 13, 2013 12:05
The deamon should never stop respawning. Way to important!
Change upstart to respawn forever
This prevents two defunct sub processes hanging around.
pclose the popened processes
Added John Ferlito contribution
Better systemd service file
Also use consistent heading.
gaul and others added 24 commits April 30, 2020 19:27
This should allow iMacs to complete tests successfully.  Fixes #212.
Fixes #215.
Removed instructions for using -t flag
Moved check_requirements function from main to mbpfan
Moved daemonize and verbose globals from main to daemon
Moved strings for program information from main to global.h
Moved strings for coretemp and applesmc paths from main to mbpfan.c
Updated Makefile
Turned on verboseness for testing
Useful for monitoring intel_pstate effects.
Run with:

clang-format -i src/*

Closes #233.
Fixes #213.  References #247.
The run directory has been moved from /var/run to /run in systemd,
which results in the following warning at boot:

```
/usr/lib/systemd/system/mbpfan.service:10: PIDFile= references a path below legacy directory /var/run/, updating /var/run/mbpfan.pid → /run/mbpfan.pid; please update the unit file accordingly.
```

Additionally, the service occasionally fails to start if the service
is started before coretemp devices have finished probing, which results
in the following error. This patch fixes this issue.

```
systemd[1]: Started A fan manager daemon for MacBook Pro.
mbpfan[350]: /usr/sbin/mbpfan needs coretemp support. Please either load it or build it into the kernel. Exiting.
systemd[1]: mbpfan.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mbpfan.service: Failed with result 'exit-code'.
systemd[1]: mbpfan.service: Scheduled restart job, restart counter is at 1.
systemd[1]: Stopped A fan manager daemon for MacBook Pro.
systemd[1]: Started A fan manager daemon for MacBook Pro.
mbpfan[369]: /usr/sbin/mbpfan needs coretemp support. Please either load it or build it into the kernel. Exiting.
systemd[1]: mbpfan.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mbpfan.service: Failed with result 'exit-code'.
systemd[1]: mbpfan.service: Scheduled restart job, restart counter is at 2.
systemd[1]: Stopped A fan manager daemon for MacBook Pro.
mbpfan[380]: /usr/sbin/mbpfan needs coretemp support. Please either load it or build it into the kernel. Exiting.
systemd[1]: Started A fan manager daemon for MacBook Pro.
systemd[1]: mbpfan.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mbpfan.service: Failed with result 'exit-code'.
systemd[1]: mbpfan.service: Scheduled restart job, restart counter is at 3.
mbpfan[393]: /usr/sbin/mbpfan needs coretemp support. Please either load it or build it into the kernel. Exiting.
systemd[1]: Stopped A fan manager daemon for MacBook Pro.
systemd[1]: Started A fan manager daemon for MacBook Pro.
systemd[1]: mbpfan.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mbpfan.service: Failed with result 'exit-code'.
systemd[1]: mbpfan.service: Scheduled restart job, restart counter is at 4.
systemd[1]: Stopped A fan manager daemon for MacBook Pro.
systemd[1]: Started A fan manager daemon for MacBook Pro.
mbpfan[416]: /usr/sbin/mbpfan needs coretemp support. Please either load it or build it into the kernel. Exiting.
systemd[1]: mbpfan.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mbpfan.service: Failed with result 'exit-code'.
systemd[1]: mbpfan.service: Scheduled restart job, restart counter is at 5.
systemd[1]: Stopped A fan manager daemon for MacBook Pro.
systemd[1]: mbpfan.service: Start request repeated too quickly.
systemd[1]: mbpfan.service: Failed with result 'exit-code'.
systemd[1]: Failed to start A fan manager daemon for MacBook Pro.
```
to reflect `PIDFile=/run/mbpfan.pid` in the service file
When building with clang-16, the following build error is raised.

clang -c -O2 -march=x86-64 -pipe -pipe -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0  -g  -Wall -Wextra -Wno-unused-function -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500 src/util.c -osrc/util.o
src/util.c:13:9: error: call to undeclared function 'vsyslog'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        vsyslog(level, fmt, args);
        ^
src/util.c:13:9: note: did you mean 'syslog'?
/usr/include/syslog.h:62:6: note: 'syslog' declared here
void syslog (int, const char *, ...);

This is due to vsyslog being available when _GNU_SOURCE or _BSD_SOURCE
is defined [1]. This patch does that, thus fixing the error.

[1]: https://linux.die.net/man/3/vsyslog

Bug: https://bugs.gentoo.org/894522
Signed-off-by: Brahmajit Das <[email protected]>
Found via clang-tidy.
Found via clang-tidy.
vsyslog() is not in POSIX, so only exposed by <syslog.h> on musl and
uclibc-ng if we define _DEFAULT_SOURCE.

https://git.musl-libc.org/cgit/musl/tree/include/syslog.h#n64
https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/sys/syslog.h#n200

While we are at it, drop the glibc-implementation-specific __USE_MISC define
in src/util.c to get rid of a double definition:

src/util.c:3: warning: "__USE_MISC" redefined
    3 | #define __USE_MISC
      |
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from src/util.c:2:
/usr/include/features.h:395: note: this is the location of the previous definition
  395 | # define __USE_MISC     1

On glibc (and uClibc-ng) the internal __USE_MISC symbol gets defined if
_DEFAULT_SOURCE is:

https://github.com/bminor/glibc/blob/master/include/features.h#L417-L419

Signed-off-by: Peter Korsgaard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.