Commit Graph

15 Commits

Author SHA1 Message Date
Max Kellermann
92c203d705 daemon: return early from daemonize_set_user()
If no "user" is configured, return from daemonize_set_user().  Save
one level of indent.
2009-02-15 16:58:52 +01:00
Max Kellermann
98994c5939 daemon: ignore "user" setting if already running as that user
If mpd.conf specifies a user, and MPD is invoked by exactly this user,
ignore the "user" setting.  Don't bother to look up its groups and
don't attempt to change uid, it won't work anyway.
2009-02-15 16:47:21 +01:00
Max Kellermann
59e62d95bd daemon: added comments to daemonize_detach() 2009-02-15 16:28:39 +01:00
Max Kellermann
42415592b4 daemon: print fork error message
Print details on why the fork() fails.
2009-02-15 16:27:50 +01:00
Max Kellermann
fd8c63b619 daemon: moved code to daemonize_detach()
Moved the code which detaches from the parent process/session to a
separate function.
2009-02-15 16:27:09 +01:00
Max Kellermann
5ba43e4ac2 daemon: removed unused variable "userpwd"
This causes a segmentation fault...
2009-01-18 18:42:44 +01:00
Max Kellermann
9c93249412 daemon: pass "detach" flag to daemonize()
This way, we don't have to pass the full "Options" object to
daemonize().
2009-01-18 18:29:30 +01:00
Max Kellermann
bfcaecabbd daemon: added daemonize_init(), daemonize_finish()
The constructor/destructor functions parse and free the configuration
properly.  This way, we don't have to load the pid file path more than
once.
2009-01-18 18:29:27 +01:00
Max Kellermann
90b34f8e6f main: moved code to daemon.c
Moved changeToUser(), cleanUpPidFile(), killFromPidFile() to
daemon.c.  These are daemonization functions.
2009-01-18 17:15:34 +01:00
Max Kellermann
4d472c265e conf: no CamelCase, part I
Renamed functions, types, variables.
2009-01-17 20:23:27 +01:00
Max Kellermann
18cb34700e daemon: don't check the setsid() return value
There is only one valid error condition for setsid(): when the current
process is already the process group leader.  This is non-critical.
2009-01-13 21:45:44 +01:00
Max Kellermann
2532129755 daemon: don't fork twice to daemonize
To detach from the parent process, fork once and make the old process
exit.  No need to do that twice.
2009-01-13 21:44:42 +01:00
Max Kellermann
cdf1eaeb2c daemon: simplified daemonize_close_stdin()
Don't bother to call fstat() or isatty() on STDIN_FILENO.
2008-12-30 16:28:18 +01:00
Max Kellermann
6c0f5fc612 listen: moved redirect_stdin() to daemon.c
redirect_stdin() is a daemonization function, and disconnecting from
the standard input is always a good idea for MPD.
2008-12-30 16:28:13 +01:00
Max Kellermann
671480814c main: moved daemonize() to daemon.c 2008-12-30 16:28:07 +01:00