Subject: Re: [PATCH 7/6] run-command: block signals between fork and execve

From: Eric Wong <[email-masked]>
Date: Fri, 14 Apr 2017 05:35:07 +0000

Eric Wong <[email-masked]> wrote:
> Brandon Williams <[email-masked]> wrote:
> > On 04/13, Eric Wong wrote:
> > > @@ -277,6 +278,8 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
> > >  		error_errno("exec '%s': cd to '%s' failed",
> > >  			    cmd->argv[0], cmd->dir);
> > >  		break;
> > > +	case CHILD_ERR_SIGPROCMASK:
> > > +		error_errno("sigprocmask failed restoring signals");
> > 
> > missing a break statement here I'll add it in, in the re-roll.
> 
> Good catch, thanks!

Actually, I now wonder if that should be die_errno instead.
sigprocmask failures (EFAULT/EINVAL) would only be due
to programmer error.

In one of my minor projects(*), I do something like this:

# define CHECK(type, expect, expr) do { \
	type checkvar = (expr); \
	assert(checkvar == (expect) && "BUG" && __FILE__ && __LINE__); \
	} while (0)

	CHECK(int, 0, sigfillset(&fullset));
	CHECK(int, 0, sigemptyset(&emptyset));
	CHECK(int, 0, pthread_sigmask(SIG_SETMASK, &fullset, NULL));

Dunno if it's considered good style or not, here.

(*) git clone git://bogomips.org/cmogstored