Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fda27ccc
Commit
fda27ccc
authored
Nov 30, 2011
by
Ken Thomases
Committed by
Alexandre Julliard
Dec 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libport: For spawnvp(_P_DETACH, ...), double-fork to avoid creating zombies.
parent
abe6a13f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
spawn.c
libs/port/spawn.c
+30
-5
No files found.
libs/port/spawn.c
View file @
fda27ccc
...
...
@@ -36,7 +36,7 @@
int
spawnvp
(
int
mode
,
const
char
*
cmdname
,
const
char
*
const
argv
[])
{
#ifndef HAVE__SPAWNVP
int
pid
=
0
,
status
,
wret
;
int
pid
,
status
,
wret
;
if
(
mode
==
_P_OVERLAY
)
{
...
...
@@ -51,20 +51,45 @@ int spawnvp(int mode, const char *cmdname, const char *const argv[])
pid
=
fork
();
if
(
pid
==
0
)
{
/* in child */
if
(
mode
==
_P_DETACH
)
{
pid
=
fork
();
if
(
pid
==
-
1
)
_exit
(
1
);
else
if
(
pid
>
0
)
_exit
(
0
);
/* else in grandchild */
}
signal
(
SIGPIPE
,
SIG_DFL
);
execvp
(
cmdname
,
(
char
**
)
argv
);
_exit
(
1
);
}
if
(
pid
!=
-
1
&&
mode
==
_P_OVERLAY
)
exit
(
0
);
if
(
pid
==
-
1
)
return
-
1
;
if
(
mode
==
_P_OVERLAY
)
exit
(
0
);
if
(
pid
!=
-
1
&&
mode
==
_P_WAIT
)
if
(
mode
==
_P_WAIT
||
mode
==
_P_DETACH
)
{
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
(
pid
==
wret
&&
WIFEXITED
(
status
))
{
if
(
mode
==
_P_WAIT
)
pid
=
WEXITSTATUS
(
status
);
else
/* mode == _P_DETACH */
if
(
WEXITSTATUS
(
status
)
!=
0
)
/* child couldn't fork grandchild */
pid
=
-
1
;
}
else
{
if
(
mode
==
_P_WAIT
)
pid
=
255
;
/* abnormal exit with an abort or an interrupt */
else
/* mode == _P_DETACH */
pid
=
-
1
;
}
}
return
pid
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment