summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-06 04:30:27 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-06 04:30:27 +0000
commita8bb4ed57719a231d4a15bda964476b0b373d03c (patch)
tree97860f4f5b8b88e20718c5bb985b13691dc6803c /win32
parent6a29dec1fde8d2d18bb3eb21f27ad45527d20734 (diff)
* process.c (proc_exec_v): follow to proc_spawn_v(). call do_aspawn()
on Win32. * process.c (rb_proc_exec): call do_spawn() on Win32. * win32/win32.c, win32/win32.h (do_spawn, do_aspawn): add mode flag. * process.c (proc_spawn_v, rb_f_system): follow above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c58
-rw-r--r--win32/win32.h4
2 files changed, 53 insertions, 9 deletions
diff --git a/win32/win32.c b/win32/win32.c
index d9c9cf3..f3ccdfe 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -630,19 +630,43 @@ pipe_exec(char *cmd, int mode, FILE **fpr, FILE **fpw)
extern VALUE rb_last_status;
int
-do_spawn(cmd)
+do_spawn(mode, cmd)
+int mode;
char *cmd;
{
- struct ChildRecord *child = CreateChild(cmd, NULL, NULL, NULL, NULL, NULL);
+ struct ChildRecord *child;
+
+ switch (mode) {
+ case P_WAIT:
+ case P_NOWAIT:
+ case P_OVERLAY:
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ child = CreateChild(cmd, NULL, NULL, NULL, NULL, NULL);
if (!child) {
return -1;
}
- rb_syswait(child->pid);
- return NUM2INT(rb_last_status);
+
+ switch (mode) {
+ case P_WAIT:
+ rb_syswait(child->pid);
+ return NUM2INT(rb_last_status);
+ case P_NOWAIT:
+ return child->pid;
+ case P_OVERLAY:
+ exit(0);
+ default:
+ return -1; /* not reached */
+ }
}
int
-do_aspawn(prog, argv)
+do_aspawn(mode, prog, argv)
+int mode;
char *prog;
char **argv;
{
@@ -650,6 +674,16 @@ char **argv;
int len, n, bs, quote;
struct ChildRecord *child;
+ switch (mode) {
+ case P_WAIT:
+ case P_NOWAIT:
+ case P_OVERLAY:
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
for (t = argv, len = 0; *t; t++) {
for (p = *t, n = quote = bs = 0; *p; ++p) {
switch (*p) {
@@ -706,8 +740,18 @@ char **argv;
if (!child) {
return -1;
}
- rb_syswait(child->pid);
- return NUM2INT(rb_last_status);
+
+ switch (mode) {
+ case P_WAIT:
+ rb_syswait(child->pid);
+ return NUM2INT(rb_last_status);
+ case P_NOWAIT:
+ return child->pid;
+ case P_OVERLAY:
+ exit(0);
+ default:
+ return -1; /* not reached */
+ }
}
static struct ChildRecord *
diff --git a/win32/win32.h b/win32/win32.h
index 0b7754b..6880b65 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -176,8 +176,8 @@ extern int chown(const char *, int, int);
extern int link(char *, char *);
extern int gettimeofday(struct timeval *, struct timezone *);
extern pid_t waitpid (pid_t, int *, int);
-extern int do_spawn(char *);
-extern int do_aspawn(char *, char **);
+extern int do_spawn(int, char *);
+extern int do_aspawn(int, char *, char **);
extern int kill(int, int);
extern pid_t rb_w32_getpid(void);