aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <egil@erlang.org>2012-03-16 17:59:00 +0100
committerPatrik Nyblom <pan@erlang.org>2012-04-17 16:12:54 +0200
commit3985e56bfa82083b23978e06809b8ab0cf9d52d8 (patch)
tree629673d880c219f43d5ec8739cfb512eee9b6276
parente2277e240790930563b0833854e7bc6a8338cf5c (diff)
downloadotp-3985e56bfa82083b23978e06809b8ab0cf9d52d8.tar.gz
otp-3985e56bfa82083b23978e06809b8ab0cf9d52d8.tar.bz2
otp-3985e56bfa82083b23978e06809b8ab0cf9d52d8.zip
Make port_info(Port,os_pid) work on Windows
-rwxr-xr-x[-rw-r--r--]erts/emulator/beam/erl_bif_info.c6
-rwxr-xr-x[-rw-r--r--]erts/emulator/beam/global.h2
-rwxr-xr-xerts/emulator/sys/win32/sys.c17
-rwxr-xr-xotp_build4
4 files changed, 19 insertions, 10 deletions
diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c
index 4dcfe997d4..2373dc7af4 100644..100755
--- a/erts/emulator/beam/erl_bif_info.c
+++ b/erts/emulator/beam/erl_bif_info.c
@@ -2927,10 +2927,10 @@ static BIF_RETTYPE port_info(Process* p, Eterm portid, Eterm item)
else if (item == am_os_pid) {
if (prt->os_pid >= 0) {
Uint hsz = 3;
- Uint n = prt->os_pid;
- (void) erts_bld_uint(NULL, &hsz, n);
+ UWord n = prt->os_pid;
+ (void) erts_bld_uword(NULL, &hsz, n);
hp = HAlloc(p, hsz);
- res = erts_bld_uint(&hp, NULL, n);
+ res = erts_bld_uword(&hp, NULL, n);
} else {
hp = HAlloc(p, 3);
res = am_undefined;
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index 9f99afd641..894872dbc0 100644..100755
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -173,7 +173,7 @@ struct port {
char *name; /* String used in the open */
erts_driver_t* drv_ptr;
UWord drv_data;
- pid_t os_pid; /* Child process ID */
+ SWord os_pid; /* Child process ID */
ErtsProcList *suspended; /* List of suspended processes. */
LineBuf *linebuf; /* Buffer to hold data not ready for
process to get (line oriented I/O)*/
diff --git a/erts/emulator/sys/win32/sys.c b/erts/emulator/sys/win32/sys.c
index b106f0932d..acbbfc2ce9 100755
--- a/erts/emulator/sys/win32/sys.c
+++ b/erts/emulator/sys/win32/sys.c
@@ -68,9 +68,9 @@ static int async_write_file(struct async_io* aio, LPVOID buf, DWORD numToWrite);
static int get_overlapped_result(struct async_io* aio,
LPDWORD pBytesRead, BOOL wait);
static BOOL create_child_process(char *, HANDLE, HANDLE,
- HANDLE, LPHANDLE, BOOL,
- LPVOID, LPTSTR, unsigned,
- char **, int *);
+ HANDLE, LPHANDLE, LPDWORD, BOOL,
+ LPVOID, LPTSTR, unsigned,
+ char **, int *);
static int create_pipe(LPHANDLE, LPHANDLE, BOOL, BOOL);
static int application_type(const char* originalName, char fullPath[MAX_PATH],
BOOL search_in_path, BOOL handle_quotes,
@@ -1136,6 +1136,7 @@ spawn_start(ErlDrvPort port_num, char* name, SysDriverOpts* opts)
HANDLE hChildStdin = INVALID_HANDLE_VALUE; /* Child's stdin. */
HANDLE hChildStdout = INVALID_HANDLE_VALUE; /* Child's stout. */
HANDLE hChildStderr = INVALID_HANDLE_VALUE; /* Child's sterr. */
+ DWORD pid;
int close_child_stderr = 0;
DriverData* dp; /* Pointer to driver data. */
ErlDrvData retval = ERL_DRV_ERROR_GENERAL; /* Return value. */
@@ -1211,6 +1212,7 @@ spawn_start(ErlDrvPort port_num, char* name, SysDriverOpts* opts)
hChildStdout,
hChildStderr,
&dp->port_pid,
+ &pid,
opts->hide_window,
(LPVOID) envir,
(LPTSTR) opts->wd,
@@ -1254,6 +1256,9 @@ spawn_start(ErlDrvPort port_num, char* name, SysDriverOpts* opts)
#endif
retval = set_driver_data(dp, hFromChild, hToChild, opts->read_write,
opts->exit_status);
+ if (retval != ERL_DRV_ERROR_GENERAL && retval != ERL_DRV_ERROR_ERRNO)
+ /* We assume that this cannot generate a negative number */
+ erts_port[port_num].os_pid = (SWord) pid;
}
if (retval != ERL_DRV_ERROR_GENERAL && retval != ERL_DRV_ERROR_ERRNO)
@@ -1397,7 +1402,8 @@ create_child_process
HANDLE hStdin, /* The standard input handle for child. */
HANDLE hStdout, /* The standard output handle for child. */
HANDLE hStderr, /* The standard error handle for child. */
- LPHANDLE phPid, /* Pointer to variable to received PID. */
+ LPHANDLE phPid, /* Pointer to variable to received Process handle. */
+ LPDWORD pdwID, /* Pointer to variable to received Process ID */
BOOL hide, /* Hide the window unconditionally. */
LPVOID env, /* Environment for the child */
LPTSTR wd, /* Working dir for the child */
@@ -1629,7 +1635,8 @@ create_child_process
}
CloseHandle(piProcInfo.hThread); /* Necessary to avoid resource leak. */
*phPid = piProcInfo.hProcess;
-
+ *pdwID = piProcInfo.dwProcessId;
+
if (applType == APPL_DOS) {
WaitForSingleObject(hProcess, 50);
}
diff --git a/otp_build b/otp_build
index 78e1b3277e..c6c73fedfa 100755
--- a/otp_build
+++ b/otp_build
@@ -1339,7 +1339,9 @@ case $TARGET in
if [ X"$OVERRIDE_TARGET" = X"" -a X"$1" != X"env_win32" -a X"$1" != X"env_msys32" -a X"$1" != X"env_msys64" ];then
echo "Building for windows, you should do the " \
"following first:" >&2
- echo 'eval `./otp_build env_msys64`' >&2
+ echo 'eval `./otp_build env_win32`' >&2
+ echo 'or' >&2
+ echo 'eval `./otp_build env_win32 x64`' >&2
echo 'please note that there are backticks (``) in' \
'the command'
exit 1