diff options
-rw-r--r-- | ChangeLog.txt | 4 | ||||
-rw-r--r-- | ports/unix/guts/system.c | 39 | ||||
-rw-r--r-- | ports/unix/wrapfuncs.in | 1 | ||||
-rw-r--r-- | pseudo_wrappers.c | 1 |
4 files changed, 45 insertions, 0 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index fec5955..64293da 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +2011-06-02: + * (seebs) intercept system() so the pseudo environment is + properly set for it. + 2011-05-31: * (seebs) Don't mask in 0100 to filesystem modes for things which are not actually directories, because this breaks the special diff --git a/ports/unix/guts/system.c b/ports/unix/guts/system.c new file mode 100644 index 0000000..99b27c0 --- /dev/null +++ b/ports/unix/guts/system.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 Wind River Systems; see + * guts/COPYRIGHT for information. + * + * int system(const char *command) + * int rc = -1; + */ + /* We want to ensure that the child process implicitly + * spawned has the right environment. So... + */ + int pid; + + if (!command) + return 1; + + pid = wrap_fork(); + + if (pid) { + int status; + waitpid(pid, &status, 0); + if (WIFEXITED(status)) { + rc = WEXITSTATUS(status); + } else { + /* we naively assume that either it exited or + * got killed by a signal... + */ + rc = WTERMSIG(status) + 128; + } + } else { + /* this involves ANOTHER fork, but it's much, much, + * simpler than trying to get all the details right. + */ + rc = real_system(command); + exit(rc); + } + +/* return rc; + * } + */ diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in index b0fdb2c..74bad89 100644 --- a/ports/unix/wrapfuncs.in +++ b/ports/unix/wrapfuncs.in @@ -54,3 +54,4 @@ int unlinkat(int dirfd, const char *path, int rflags); /* flags=AT_SYMLINK_NOFOL # primarily for use with chroot() ssize_t readlink(const char *path, char *buf, size_t bufsiz); /* flags=AT_SYMLINK_NOFOLLOW */ ssize_t readlinkat(int dirfd, const char *path, char *buf, size_t bufsiz); /* flags=AT_SYMLINK_NOFOLLOW */ +int system(const char *command); diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c index dd4a800..600a918 100644 --- a/pseudo_wrappers.c +++ b/pseudo_wrappers.c @@ -31,6 +31,7 @@ #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> +#include <sys/wait.h> #include <dlfcn.h> /* used for various specific function arguments */ |