aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-14 00:45:51 +0200
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 11:04:33 +1000
commitb6146507960ce0f32609c2e3bc5b38ee308492ea (patch)
tree909d2e659f5cd549bd9a1535f8971cf4069bc049 /shell
parentaefcdde7da9eff70aa94ae30633f861068b943e3 (diff)
downloadbusybox-w32-b6146507960ce0f32609c2e3bc5b38ee308492ea.tar.gz
busybox-w32-b6146507960ce0f32609c2e3bc5b38ee308492ea.tar.bz2
busybox-w32-b6146507960ce0f32609c2e3bc5b38ee308492ea.zip
win32: ash: evalbackcmd
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index b2b246dfe..5341ef75f 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 */
5932static void evaltree(union node *, int); 5933static void evaltree(union node *, int);
5933 5934
5935#if ENABLE_PLATFORM_MINGW32
5936static void
5937forkshell_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
5934static void FAST_FUNC 5954static void FAST_FUNC
5935evalbackcmd(union node *n, struct backcmd *result) 5955evalbackcmd(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]);
@@ -13216,6 +13245,7 @@ extern int etext();
13216#if ENABLE_PLATFORM_MINGW32 13245#if ENABLE_PLATFORM_MINGW32
13217static const forkpoint_fn forkpoints[] = { 13246static const forkpoint_fn forkpoints[] = {
13218 forkshell_openhere, 13247 forkshell_openhere,
13248 forkshell_evalbackcmd,
13219 NULL 13249 NULL
13220}; 13250};
13221 13251