summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@engin.umich.edu>1997-06-24 10:49:12 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit6890e559d7ce8a57fe2b6b18ef51d300ce98843f (patch)
tree80495b2027569001ce15fa521efa9ce066381298
parentb4793f7f58b137d8b2f6d505d6c77dee2cd8cb25 (diff)
downloadperl-6890e559d7ce8a57fe2b6b18ef51d300ce98843f.tar.gz
exec() fixed on win32
exec() doesn't work right on Win32 because of the UNIX-specific do_exec(). This patch fixes that, and updates the README.win32 in spots. p5p-msgid: 199706241525.LAA06554@aatma.engin.umich.edu
-rw-r--r--README.win3212
-rw-r--r--doio.c4
-rw-r--r--win32/config_H.bc2
-rw-r--r--win32/config_H.vc2
-rw-r--r--win32/makedef.pl1
-rw-r--r--win32/win32.c59
-rw-r--r--win32/win32.h1
-rw-r--r--win32/win32io.c1
-rw-r--r--win32/win32io.h3
-rw-r--r--win32/win32iop.h2
10 files changed, 75 insertions, 12 deletions
diff --git a/README.win32 b/README.win32
index 8d14a2da4c..0cd070a6e9 100644
--- a/README.win32
+++ b/README.win32
@@ -337,7 +337,7 @@ all of the Activeware extensions and most other Win32 extensions from
CPAN in source form, along with many added bugfixes, and with MakeMaker
support. This bundle is available at:
- http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.06.tar.gz
+ http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.07.tar.gz
See the README in that distribution for building and installation
instructions. Look for later versions that may be available at the
@@ -404,13 +404,19 @@ bogus.
=item *
-The following functions are currently unavailable: C<fork()>, C<exec()>,
+The following functions are currently unavailable: C<fork()>,
C<dump()>, C<chown()>, C<link()>, C<symlink()>, C<chroot()>,
C<setpgrp()>, C<getpgrp()>, C<setpriority()>, C<getpriority()>,
C<syscall()>, C<fcntl()>. This list is possibly very incomplete.
=item *
+crypt() is not available due to silly export restrictions. It may
+become available when the laws change. Meanwhile, look in CPAN for
+extensions that provide it.
+
+=item *
+
Various C<socket()> related calls are supported, but they may not
behave as on Unix platforms.
@@ -488,7 +494,7 @@ sundry hacks since then.
Borland support was added in 5.004_01 (Gurusamy Sarathy).
-Last updated: 11 June 1997
+Last updated: 15 June 1997
=cut
diff --git a/doio.c b/doio.c
index f98af9bf6f..8373d09368 100644
--- a/doio.c
+++ b/doio.c
@@ -942,7 +942,7 @@ do_execfree()
}
}
-#ifndef OS2
+#if !defined(OS2) && !defined(WIN32)
bool
do_exec(cmd)
@@ -1033,7 +1033,7 @@ char *cmd;
return FALSE;
}
-#endif /* OS2 */
+#endif /* OS2 || WIN32 */
I32
apply(type,mark,sp)
diff --git a/win32/config_H.bc b/win32/config_H.bc
index 5976289777..ef1193e222 100644
--- a/win32/config_H.bc
+++ b/win32/config_H.bc
@@ -1687,7 +1687,7 @@
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd /x /c" /**/
+#define SH_PATH "cmd.exe" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
diff --git a/win32/config_H.vc b/win32/config_H.vc
index ced62a11c8..36a9a5b0d4 100644
--- a/win32/config_H.vc
+++ b/win32/config_H.vc
@@ -1687,7 +1687,7 @@
* /bin/pdksh, /bin/ash, /bin/bash, or even something such as
* D:/bin/sh.exe.
*/
-#define SH_PATH "cmd /x /c" /**/
+#define SH_PATH "cmd.exe" /**/
/* SIG_NAME:
* This symbol contains a list of signal names in order of
diff --git a/win32/makedef.pl b/win32/makedef.pl
index 73380b4b55..82c3da5133 100644
--- a/win32/makedef.pl
+++ b/win32/makedef.pl
@@ -275,6 +275,7 @@ win32_mkdir
win32_rmdir
win32_chdir
win32_flock
+win32_execvp
win32_htons
win32_ntohs
win32_htonl
diff --git a/win32/win32.c b/win32/win32.c
index 4663f86938..3d226ce998 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -31,6 +31,10 @@
#define CROAK croak
#define WARN warn
+#define EXECF_EXEC 1
+#define EXECF_SPAWN 2
+#define EXECF_SPAWN_NOWAIT 3
+
static DWORD IdOS(void);
extern WIN32_IOSUBSYSTEM win32stdio;
@@ -42,6 +46,8 @@ char szShellPath[MAX_PATH+1];
char szPerlLibRoot[MAX_PATH+1];
HANDLE PerlDllHandle = INVALID_HANDLE_VALUE;
+static int do_spawn2(char *cmd, int exectype);
+
int
IsWin95(void) {
return (IdOS() == VER_PLATFORM_WIN32_WINDOWS);
@@ -390,7 +396,7 @@ do_aspawn(void* really, void** mark, void** arglast)
}
int
-do_spawn(char *cmd)
+do_spawn2(char *cmd, int exectype)
{
char **a;
char *s;
@@ -420,7 +426,19 @@ do_spawn(char *cmd)
}
*a = Nullch;
if(argv[0]) {
- status = win32_spawnvp(P_WAIT, argv[0], (const char* const*)argv);
+ switch (exectype) {
+ case EXECF_SPAWN:
+ status = win32_spawnvp(P_WAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_SPAWN_NOWAIT:
+ status = win32_spawnvp(P_NOWAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_EXEC:
+ status = win32_execvp(argv[0], (const char* const*)argv);
+ break;
+ }
if(status != -1 || errno == 0)
needToTry = FALSE;
}
@@ -431,17 +449,44 @@ do_spawn(char *cmd)
char *argv[5];
argv[0] = shell; argv[1] = "/x"; argv[2] = "/c";
argv[3] = cmd; argv[4] = Nullch;
- status = win32_spawnvp(P_WAIT, argv[0], (const char* const*)argv);
+ switch (exectype) {
+ case EXECF_SPAWN:
+ status = win32_spawnvp(P_WAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_SPAWN_NOWAIT:
+ status = win32_spawnvp(P_NOWAIT, argv[0],
+ (const char* const*)argv);
+ break;
+ case EXECF_EXEC:
+ status = win32_execvp(argv[0], (const char* const*)argv);
+ break;
+ }
}
if (status < 0) {
if (dowarn)
- warn("Can't spawn \"%s\": %s", needToTry ? shell : argv[0],
+ warn("Can't %s \"%s\": %s",
+ (exectype == EXECF_EXEC ? "exec" : "spawn"),
+ needToTry ? shell : argv[0],
strerror(errno));
status = 255 << 8;
}
return (status);
}
+int
+do_spawn(char *cmd)
+{
+ return do_spawn2(cmd, EXECF_SPAWN);
+}
+
+bool
+do_exec(char *cmd)
+{
+ do_spawn2(cmd, EXECF_EXEC);
+ return FALSE;
+}
+
#define PATHLEN 1024
@@ -1107,6 +1152,12 @@ win32_spawnvp(int mode, const char *cmdname, const char *const *argv)
return pIOSubSystem->pfnspawnvp(mode, cmdname, argv);
}
+DllExport int
+win32_execvp(const char *cmdname, const char *const *argv)
+{
+ return pIOSubSystem->pfnexecvp(cmdname, argv);
+}
+
int
stolen_open_osfhandle(long handle, int flags)
{
diff --git a/win32/win32.h b/win32/win32.h
index d295a75a35..c6746d2900 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -104,6 +104,7 @@ int mytimes(struct tms *timebuf);
unsigned int myalarm(unsigned int sec);
int do_aspawn(void* really, void** mark, void** arglast);
int do_spawn(char *cmd);
+char do_exec(char *cmd);
typedef char * caddr_t; /* In malloc.c (core address). */
diff --git a/win32/win32io.c b/win32/win32io.c
index 0651781342..96ceb3eabe 100644
--- a/win32/win32io.c
+++ b/win32/win32io.c
@@ -297,6 +297,7 @@ WIN32_IOSUBSYSTEM win32stdio = {
_rmdir,
_chdir,
my_flock, /* (*pfunc_flock)(int fd, int oper) */
+ execvp,
87654321L, /* end of structure */
};
diff --git a/win32/win32io.h b/win32/win32io.h
index 678327cd20..98ee874996 100644
--- a/win32/win32io.h
+++ b/win32/win32io.h
@@ -60,7 +60,8 @@ int (*pfnmkdir)(const char *path);
int (*pfnrmdir)(const char *path);
int (*pfnchdir)(const char *path);
int (*pfnflock)(int fd, int oper);
-int signature_end;
+int (*pfnexecvp)(const char *cmdname, const char *const *argv);
+int signature_end;
} WIN32_IOSUBSYSTEM;
typedef WIN32_IOSUBSYSTEM *PWIN32_IOSUBSYSTEM;
diff --git a/win32/win32iop.h b/win32/win32iop.h
index 4b4b9973d3..6ec25b0c3a 100644
--- a/win32/win32iop.h
+++ b/win32/win32iop.h
@@ -63,6 +63,7 @@ EXT int win32_mkdir(const char *dir, int mode);
EXT int win32_rmdir(const char *dir);
EXT int win32_chdir(const char *dir);
EXT int win32_flock(int fd, int oper);
+EXT int win32_execvp(const char *cmdname, const char *const *argv);
/*
* these two are win32 specific but still io related
@@ -154,6 +155,7 @@ void * SetIOSubSystem(void *piosubsystem);
#define rmdir win32_rmdir
#define chdir win32_chdir
#define flock(fd,o) win32_flock(fd,o)
+#define execvp win32_execvp
#endif /* WIN32IO_IS_STDIO */
#endif /* WIN32IOP_H */