diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:31:57 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-06-04 18:31:57 +0000 |
commit | 09e967c2d732783b2579e4e120cd9b608404cb00 (patch) | |
tree | 8d2783a6a7e33608c6012efd6a88b8f5694df81d /mdk-stage1/dietlibc/libugly/system.c | |
parent | 18fcff49d3c836697d3b75a3d01d31c700e69974 (diff) | |
download | drakx-backup-do-not-use-09e967c2d732783b2579e4e120cd9b608404cb00.tar drakx-backup-do-not-use-09e967c2d732783b2579e4e120cd9b608404cb00.tar.gz drakx-backup-do-not-use-09e967c2d732783b2579e4e120cd9b608404cb00.tar.bz2 drakx-backup-do-not-use-09e967c2d732783b2579e4e120cd9b608404cb00.tar.xz drakx-backup-do-not-use-09e967c2d732783b2579e4e120cd9b608404cb00.zip |
Merge from R9_0-AMD64, most notably:
- AMD64 support to insmod-busybox, minilibc, et al.
- Sync with insmod-modutils 2.4.19 something but everyone should use
dietlibc nowadays
- Factor out compilation and prefix with $(DIET) for dietlibc builds
- 64-bit & varargs fixes
Diffstat (limited to 'mdk-stage1/dietlibc/libugly/system.c')
-rw-r--r-- | mdk-stage1/dietlibc/libugly/system.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/mdk-stage1/dietlibc/libugly/system.c b/mdk-stage1/dietlibc/libugly/system.c index b9eea20eb..714aad056 100644 --- a/mdk-stage1/dietlibc/libugly/system.c +++ b/mdk-stage1/dietlibc/libugly/system.c @@ -1,23 +1,19 @@ #include <signal.h> -#include <asm/errno.h> #include <errno.h> #include <unistd.h> +#include <sys/wait.h> #include "dietwarning.h" - -#define SHELL_PATH "/bin/sh" /* Path of the shell. */ -#define SHELL_NAME "sh" /* Name to give it. */ +#include "dietfeatures.h" +#include "binshstr.h" extern char **environ; -int __libc_fork(); -int __libc_waitpid(int pid, int *status, int options); -int execve(const char*filename, char *const argv[], char *const envp[]); -void __set_errno(int errno); -int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); +int __libc_system (const char *line); int __libc_system (const char *line) { struct sigaction sa, intr, quit; + sigset_t block,omask; int save,pid,ret=-1; if (line == 0) return __libc_system("exit 0") == 0; @@ -29,38 +25,48 @@ int __libc_system (const char *line) if (sigaction(SIGINT, &sa, &intr)<0) return -1; if (sigaction(SIGQUIT, &sa, &quit)<0) { save = errno; +undo: sigaction (SIGINT, &intr, (struct sigaction*)0); - __set_errno (save); + errno=save; return -1; } + sigemptyset(&block); + sigaddset(&block,SIGCHLD); + if (sigprocmask(SIG_BLOCK,&block,&omask)<0) { + save=errno; + sigaction (SIGQUIT, &quit, (struct sigaction*)0); + goto undo; + } - pid=__libc_fork(); + pid=fork(); if (pid>0) { /* parent */ int n; do - n=__libc_waitpid(pid, &ret, 0); + n=waitpid(pid, &ret, 0); while ((n==-1) && (errno==EINTR)); if (n!=pid) ret=-1; } else if (!pid) { /* child */ const char *nargs[4]; - nargs[0] = SHELL_NAME; + nargs[0] = __sh; nargs[1] = "-c"; nargs[2] = line; nargs[3] = 0; sigaction(SIGINT, &intr, (struct sigaction*)0); sigaction(SIGQUIT, &quit, (struct sigaction*)0); + sigprocmask(SIG_SETMASK,&omask,0); - execve(SHELL_PATH,(char *const *)nargs, environ); + execve(__binsh,(char *const *)nargs, environ); _exit(127); } save = errno; sigaction (SIGINT, &intr, (struct sigaction *)0); sigaction (SIGQUIT, &quit, (struct sigaction *)0); - __set_errno(save); + sigprocmask(SIG_SETMASK,&omask,0); + errno=save; return ret; } |