[sheepdog] [PATCH] sheep: let sheep return correct exit status when locking a base directory fails
MORITA Kazutaka
morita.kazutaka at gmail.com
Mon May 13 17:33:09 CEST 2013
>
> @@ -402,36 +407,51 @@ static int lock_and_daemon(bool daemonize, const char *base_dir)
> panic("fork() failed during daemonize: %m");
> break;
> default:
> - exit(0);
> + ret = read(pipefd[0], &status, sizeof(status));
> + if (ret != sizeof(status))
> + panic("read exit status failed: %m");
> +
> + exit(status);
> break;
> }
>
> - if (setsid() == -1)
> - panic("becoming a leader of a new session failed: %m");
> + if (setsid() == -1) {
> + sd_eprintf("becoming a leader of a new session"
> + " failed: %m");
> + status = 1;
> + goto end;
> + }
>
> switch (fork()) {
> case 0:
> break;
> case -1:
> - panic("fork() failed during daemonize: %m");
> - break;
> + sd_eprintf("fork() failed during daemonize: %m");
> + goto end;
> default:
I think we need to set 'status' to 1 here.
Thanks,
Kazutaka
More information about the sheepdog
mailing list