Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
info.mailfrom = mailfrom;
info.dosyslog = dosyslog;
- if (daemonise)
- if (make_daemon(pidfile))
- return 1;
+ if (daemonise) {
+ int rv = make_daemon(pidfile);
+ if (rv >= 0)
+ return rv;
+ }
if (share)
if (check_one_sharer(scan))
static int make_daemon(char *pidfile)
{
+ /* Return:
+ * -1 in the forked daemon
+ * 0 in the parent
+ * 1 on error
+ * so a none-negative becomes the exit code.
+ */
int pid = fork();
if (pid > 0) {
if (!pidfile)
dup2(0,1);
dup2(0,2);
setsid();
- return 0;
+ return -1;
}
static int check_one_sharer(int scan)