diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-14 00:45:51 +0200 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-20 19:14:52 +0200 |
commit | 1d847e4b4dfa1699d7b65434ec75546791de4b96 (patch) | |
tree | ccd586c37c54b65a81269710b2f7d8a91fdffc7a /shell | |
parent | 9b4b51d0530d804c178d8531d60cb0335c22085c (diff) | |
download | busybox-w32-1d847e4b4dfa1699d7b65434ec75546791de4b96.tar.gz busybox-w32-1d847e4b4dfa1699d7b65434ec75546791de4b96.tar.bz2 busybox-w32-1d847e4b4dfa1699d7b65434ec75546791de4b96.zip |
win32: ash: evalbackcmd
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index 007009245..2b9b2226e 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -5923,6 +5923,7 @@ struct backcmd { /* result of evalbackcmd */ | |||
5923 | int fd; /* file descriptor to read from */ | 5923 | int fd; /* file descriptor to read from */ |
5924 | int nleft; /* number of chars in buffer */ | 5924 | int nleft; /* number of chars in buffer */ |
5925 | char *buf; /* buffer */ | 5925 | char *buf; /* buffer */ |
5926 | IF_PLATFORM_MINGW32(struct forkshell fs); | ||
5926 | struct job *jp; /* job structure for command */ | 5927 | struct job *jp; /* job structure for command */ |
5927 | }; | 5928 | }; |
5928 | 5929 | ||
@@ -5931,6 +5932,25 @@ static uint8_t back_exitstatus; /* exit status of backquoted command */ | |||
5931 | #define EV_EXIT 01 /* exit after evaluating tree */ | 5932 | #define EV_EXIT 01 /* exit after evaluating tree */ |
5932 | static void evaltree(union node *, int); | 5933 | static void evaltree(union node *, int); |
5933 | 5934 | ||
5935 | #if ENABLE_PLATFORM_MINGW32 | ||
5936 | static void | ||
5937 | forkshell_evalbackcmd(struct forkshell *fs) | ||
5938 | { | ||
5939 | union node *n = fs->n; | ||
5940 | int pip[2] = {fs->fd[0], fs->fd[1]}; | ||
5941 | |||
5942 | FORCE_INT_ON; | ||
5943 | close(pip[0]); | ||
5944 | if (pip[1] != 1) { | ||
5945 | /*close(1);*/ | ||
5946 | copyfd(pip[1], 1 | COPYFD_EXACT); | ||
5947 | close(pip[1]); | ||
5948 | } | ||
5949 | eflag = 0; | ||
5950 | evaltree(n, EV_EXIT); /* actually evaltreenr... */ | ||
5951 | /* NOTREACHED */ | ||
5952 | } | ||
5953 | #endif | ||
5934 | static void FAST_FUNC | 5954 | static void FAST_FUNC |
5935 | evalbackcmd(union node *n, struct backcmd *result) | 5955 | evalbackcmd(union node *n, struct backcmd *result) |
5936 | { | 5956 | { |
@@ -5939,6 +5959,7 @@ evalbackcmd(union node *n, struct backcmd *result) | |||
5939 | result->fd = -1; | 5959 | result->fd = -1; |
5940 | result->buf = NULL; | 5960 | result->buf = NULL; |
5941 | result->nleft = 0; | 5961 | result->nleft = 0; |
5962 | IF_PLATFORM_MINGW32(memset(&result->fs, 0, sizeof(result->fs))); | ||
5942 | result->jp = NULL; | 5963 | result->jp = NULL; |
5943 | if (n == NULL) | 5964 | if (n == NULL) |
5944 | goto out; | 5965 | goto out; |
@@ -5953,6 +5974,14 @@ evalbackcmd(union node *n, struct backcmd *result) | |||
5953 | if (pipe(pip) < 0) | 5974 | if (pipe(pip) < 0) |
5954 | ash_msg_and_raise_error("pipe call failed"); | 5975 | ash_msg_and_raise_error("pipe call failed"); |
5955 | jp = makejob(/*n,*/ 1); | 5976 | jp = makejob(/*n,*/ 1); |
5977 | #if ENABLE_PLATFORM_MINGW32 | ||
5978 | result->fs.fp = forkshell_evalbackcmd; | ||
5979 | result->fs.n = n; | ||
5980 | result->fs.fd[0] = pip[0]; | ||
5981 | result->fs.fd[1] = pip[1]; | ||
5982 | if (spawn_forkshell(jp, &result->fs, FORK_NOJOB) < 0) | ||
5983 | ash_msg_and_raise_error("unable to spawn shell"); | ||
5984 | #endif | ||
5956 | if (forkshell(jp, n, FORK_NOJOB) == 0) { | 5985 | if (forkshell(jp, n, FORK_NOJOB) == 0) { |
5957 | FORCE_INT_ON; | 5986 | FORCE_INT_ON; |
5958 | close(pip[0]); | 5987 | close(pip[0]); |
@@ -13215,6 +13244,7 @@ extern int etext(); | |||
13215 | #if ENABLE_PLATFORM_MINGW32 | 13244 | #if ENABLE_PLATFORM_MINGW32 |
13216 | static const forkpoint_fn forkpoints[] = { | 13245 | static const forkpoint_fn forkpoints[] = { |
13217 | forkshell_openhere, | 13246 | forkshell_openhere, |
13247 | forkshell_evalbackcmd, | ||
13218 | NULL | 13248 | NULL |
13219 | }; | 13249 | }; |
13220 | 13250 | ||