Module: wine Branch: master Commit: 5206c7147210cf6578c5cda8bbf60867f0fca39c URL: https://gitlab.winehq.org/wine/wine/-/commit/5206c7147210cf6578c5cda8bbf6086...
Author: Brendan Shanks bshanks@codeweavers.com Date: Fri Sep 1 16:10:08 2023 -0700
tools: Use posix_spawn() instead of fork()/execvp().
---
tools/tools.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/tools/tools.h b/tools/tools.h index fa459994eb3..7f99205aca8 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -57,6 +57,8 @@ # define strcasecmp _stricmp # endif #else +extern char **environ; +# include <spawn.h> # include <sys/wait.h> # include <unistd.h> # ifndef O_BINARY @@ -283,13 +285,9 @@ static inline int strarray_spawn( struct strarray args ) pid_t pid, wret; int status;
- if (!(pid = fork())) - { - strarray_add( &args, NULL ); - execvp( args.str[0], (char **)args.str ); - _exit(1); - } - if (pid == -1) return -1; + strarray_add( &args, NULL ); + if (posix_spawnp( &pid, args.str[0], NULL, NULL, (char **)args.str, environ )) + return -1;
while (pid != (wret = waitpid( pid, &status, 0 ))) if (wret == -1 && errno != EINTR) break;