[sheepdog] [PATCH] sheep: let sheep return correct exit status when locking a base directory fails

Hitoshi Mitake mitake.hitoshi at gmail.com
Mon May 13 22:03:12 CEST 2013


At Tue, 14 May 2013 00:33:09 +0900,
MORITA Kazutaka wrote:
> 
> > 
> > @@ -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 for your pointing, I'll fix it in v2.

Thanks,
Hitoshi



More information about the sheepdog mailing list