зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
6a29dec1fd
Коммит
a8bb4ed577
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Mon Jan 6 13:26:35 2003 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* 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.
|
||||
|
||||
Mon Jan 06 05:11:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* ext/extmk.rb: make $0 normal variable.
|
||||
|
|
32
process.c
32
process.c
|
@ -441,17 +441,13 @@ proc_exec_v(argv, prog)
|
|||
char **argv;
|
||||
char *prog;
|
||||
{
|
||||
if (prog) {
|
||||
security(prog);
|
||||
}
|
||||
else {
|
||||
security(argv[0]);
|
||||
prog = dln_find_exe(argv[0], 0);
|
||||
if (!prog) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!prog)
|
||||
prog = argv[0];
|
||||
security(prog);
|
||||
prog = dln_find_exe(prog, 0);
|
||||
if (!prog)
|
||||
return -1;
|
||||
|
||||
#if (defined(MSDOS) && !defined(DJGPP)) || defined(__human68k__) || defined(__EMX__) || defined(OS2)
|
||||
{
|
||||
#if defined(__human68k__)
|
||||
|
@ -490,7 +486,11 @@ proc_exec_v(argv, prog)
|
|||
}
|
||||
#endif /* MSDOS or __human68k__ or __EMX__ */
|
||||
before_exec();
|
||||
#ifdef _WIN32
|
||||
do_aspawn(P_OVERLAY, prog, argv);
|
||||
#else
|
||||
execv(prog, argv);
|
||||
#endif
|
||||
after_exec();
|
||||
return -1;
|
||||
}
|
||||
|
@ -531,6 +531,11 @@ rb_proc_exec(str)
|
|||
while (*str && ISSPACE(*str))
|
||||
str++;
|
||||
|
||||
#ifdef _WIN32
|
||||
before_exec();
|
||||
do_spawn(P_OVERLAY, (char *)str);
|
||||
after_exec();
|
||||
#else
|
||||
for (s=str; *s; s++) {
|
||||
if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) {
|
||||
#if defined(MSDOS)
|
||||
|
@ -574,6 +579,7 @@ rb_proc_exec(str)
|
|||
return proc_exec_v(argv, 0);
|
||||
}
|
||||
errno = ENOENT;
|
||||
#endif /* _WIN32 */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -619,7 +625,7 @@ proc_spawn_v(argv, prog)
|
|||
#endif
|
||||
before_exec();
|
||||
#if defined(_WIN32)
|
||||
status = do_aspawn(prog, argv);
|
||||
status = do_aspawn(P_WAIT, prog, argv);
|
||||
#else
|
||||
status = spawnv(P_WAIT, prog, argv);
|
||||
#endif
|
||||
|
@ -860,7 +866,7 @@ rb_f_system(argc, argv)
|
|||
|
||||
if (argc == 1 && prog == 0) {
|
||||
#if defined(_WIN32)
|
||||
status = do_spawn(RSTRING(argv[0])->ptr);
|
||||
status = do_spawn(P_WAIT, RSTRING(argv[0])->ptr);
|
||||
#else
|
||||
status = proc_spawn(argv[0]);
|
||||
#endif
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче