file: patch process stdin to /dev/null
This prevents broken pipe errors in executed child processes that attempt to access stdin. Suggested-by: Vytautas Virvičius <vy.virvicius@gmail.com> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
2e8106ac56
commit
67118a6b33
1 changed files with 8 additions and 1 deletions
9
file.c
9
file.c
|
@ -597,6 +597,7 @@ rpc_file_exec_run(const char *cmd,
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
int devnull;
|
||||||
int opipe[2];
|
int opipe[2];
|
||||||
int epipe[2];
|
int epipe[2];
|
||||||
|
|
||||||
|
@ -629,10 +630,16 @@ rpc_file_exec_run(const char *cmd,
|
||||||
case 0:
|
case 0:
|
||||||
uloop_done();
|
uloop_done();
|
||||||
|
|
||||||
|
devnull = open("/dev/null", O_RDWR);
|
||||||
|
|
||||||
|
if (devnull == -1)
|
||||||
|
return UBUS_STATUS_UNKNOWN_ERROR;
|
||||||
|
|
||||||
|
dup2(devnull, 0);
|
||||||
dup2(opipe[1], 1);
|
dup2(opipe[1], 1);
|
||||||
dup2(epipe[1], 2);
|
dup2(epipe[1], 2);
|
||||||
|
|
||||||
close(0);
|
close(devnull);
|
||||||
close(opipe[0]);
|
close(opipe[0]);
|
||||||
close(opipe[1]);
|
close(opipe[1]);
|
||||||
close(epipe[0]);
|
close(epipe[0]);
|
||||||
|
|
Loading…
Reference in a new issue