Made `REPLACE_STDERR` only replace execve()"d process" stderr; the parent now has its own, private stderr that is closed on exec so can properly report errors.
@ -20,7 +20,7 @@ Run `make && sudo make install` to build with full optimisations and install `si
To build for debugging, run `make debug`.
To build for debugging, run `make debug`.
### Compiler flags
### Compiler flags
* `-DREPLACE_STDERR` - Add to `CFLAGS` when building a target to re-route the program's `stderr` stream to the sink as well. By default, it is left open.
* `-DREPLACE_STDERR` - Add to `CFLAGS` when building a target to re-route the child program's `stderr` stream to the sink as well. By default, it is passed through as default.
* `-DNO_SEARCH_PATH` - Add to `CFLAGS` when building to prevent the program looking up its argument in the `PATH` environment variable.
* `-DNO_SEARCH_PATH` - Add to `CFLAGS` when building to prevent the program looking up its argument in the `PATH` environment variable.
* `-DNO_ENV` - Add to `CFLAGS` when building to prevent `envp` passthrough to the `execve()`'d program.
* `-DNO_ENV` - Add to `CFLAGS` when building to prevent `envp` passthrough to the `execve()`'d program.
* `-DDEBUG_IGNORE_SPLASH` - Do not print project and version info in debug builds on startup.
* `-DDEBUG_IGNORE_SPLASH` - Do not print project and version info in debug builds on startup.
}elseif(UNLIKELY(pfd(sfd)<0))return(perror("failed to (redundantly?) FD_CLOEXEC b_stderrr"),0);// TODO: XXX: Does dup2() copy the CLOEXEC flag? Find out, and it it does, remove this line.
}//else if(UNLIKELY( pfd(sfd) < 0 )) return (perror("failed to (redundantly?) FD_CLOEXEC b_stderrr"),0); // TODO: XXX: Does dup2() copy the CLOEXEC flag? Find out, and it it does, remove this line.
#else
if(UNLIKELY(!fdreopen(&stderr,b_stderr,"wb"))){
perror("failed to reopen parent stderr with pdup()'d stream");
return0;
}
#endif
return1;
return1;
}
}
@ -59,17 +91,16 @@ static inline int dupall(int from)
return2;
return2;
}
}
#ifdef REPLACE_STDERR
// Save parent's stderr to a private one
if(UNLIKELY(!save_stderr())){
if(UNLIKELY(!save_stderr())){
return3;
return3;
}
}
#if defined(REPLACE_STDERR) && !defined(DEBUG) /* XXX: We may be removing this section soon, for now just leave it though */