Reset SIGCHLD handler to default if we need to wait. Reset SIGPIPE
handler before exec.
This commit is contained in:
parent
7c836cf954
commit
fa9af1d0dc
@ -22,6 +22,7 @@
|
|||||||
#include "wine/port.h"
|
#include "wine/port.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
#ifdef HAVE_SYS_WAIT_H
|
#ifdef HAVE_SYS_WAIT_H
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
@ -34,19 +35,39 @@ int spawnvp(int mode, const char *cmdname, char *const argv[])
|
|||||||
{
|
{
|
||||||
#ifndef HAVE__SPAWNVP
|
#ifndef HAVE__SPAWNVP
|
||||||
int pid = 0, status, wret;
|
int pid = 0, status, wret;
|
||||||
|
struct sigaction dfl_act, old_act;
|
||||||
|
|
||||||
if (mode != _P_OVERLAY) pid = fork();
|
if (mode == _P_OVERLAY)
|
||||||
if (pid == 0) pid = execvp(argv[0], argv);
|
{
|
||||||
if (pid < 0) return -1;
|
execvp(cmdname, argv);
|
||||||
|
return -1; /* if we get here it failed */
|
||||||
|
}
|
||||||
|
|
||||||
if (mode != _P_WAIT) return pid;
|
dfl_act.sa_handler = SIG_DFL;
|
||||||
|
dfl_act.sa_flags = 0;
|
||||||
|
sigemptyset( &dfl_act.sa_mask );
|
||||||
|
|
||||||
while (pid != (wret = waitpid(pid, &status, 0)))
|
if (mode == _P_WAIT) sigaction( SIGCHLD, &dfl_act, &old_act );
|
||||||
if (wret == -1 && errno != EINTR) break;
|
|
||||||
|
|
||||||
if (pid == wret && WIFEXITED(status)) return WEXITSTATUS(status);
|
pid = fork();
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
sigaction( SIGPIPE, &dfl_act, NULL );
|
||||||
|
execvp(cmdname, argv);
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
return 255; /* abnormal exit with an abort or an interrupt */
|
if (pid != -1 && mode == _P_WAIT)
|
||||||
|
{
|
||||||
|
while (pid != (wret = waitpid(pid, &status, 0)))
|
||||||
|
if (wret == -1 && errno != EINTR) break;
|
||||||
|
|
||||||
|
if (pid == wret && WIFEXITED(status)) pid = WEXITSTATUS(status);
|
||||||
|
else pid = 255; /* abnormal exit with an abort or an interrupt */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == _P_WAIT) sigaction( SIGCHLD, &old_act, NULL );
|
||||||
|
return pid;
|
||||||
#else /* HAVE__SPAWNVP */
|
#else /* HAVE__SPAWNVP */
|
||||||
return _spawnvp(mode, cmdname, argv);
|
return _spawnvp(mode, cmdname, argv);
|
||||||
#endif /* HAVE__SPAWNVP */
|
#endif /* HAVE__SPAWNVP */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user