mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[osdep] initialize ret
This commit is contained in:
parent
dabfe8dbbd
commit
aa7edfc16d
@ -352,27 +352,28 @@ exe(char *path)
|
||||
|
||||
int
|
||||
exe_no_stdin(char *path) {
|
||||
int ret;
|
||||
int ret = 0;
|
||||
#ifndef WIN32
|
||||
|
||||
#if defined(F_GETFD) && defined(FD_CLOEXEC)
|
||||
int flags;
|
||||
|
||||
flags = fcntl(STDIN_FILENO, F_GETFD);
|
||||
fcntl(STDIN_FILENO, F_SETFD, flags | FD_CLOEXEC);
|
||||
ret = exe(path);
|
||||
fcntl(STDIN_FILENO, F_SETFD, flags);
|
||||
#else
|
||||
pid_t pid;
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(STDIN_FILENO);
|
||||
exit(exe(path));
|
||||
}
|
||||
else if (pid > 0)
|
||||
waitpid(pid, &ret, 0);
|
||||
#endif
|
||||
#if defined(F_GETFD) && defined(FD_CLOEXEC)
|
||||
int flags;
|
||||
|
||||
flags = fcntl(STDIN_FILENO, F_GETFD);
|
||||
fcntl(STDIN_FILENO, F_SETFD, flags | FD_CLOEXEC);
|
||||
ret = exe(path);
|
||||
fcntl(STDIN_FILENO, F_SETFD, flags);
|
||||
#else
|
||||
pid_t pid;
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(STDIN_FILENO);
|
||||
exit(exe(path));
|
||||
}
|
||||
else if (pid > 0)
|
||||
waitpid(pid, &ret, 0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user