summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnantha Kesari H Y <hyanantha@php.net>2005-07-01 06:49:29 +0000
committerAnantha Kesari H Y <hyanantha@php.net>2005-07-01 06:49:29 +0000
commit98a2eeacc7413b6d2db427e722ada0cd7c9b1d30 (patch)
tree6e38a59553fa0f3c0ba85efe897e012bd9bb09b2
parent6e4d1b9be662f1ad278fdded8f28e095865d13f9 (diff)
downloadphp-git-98a2eeacc7413b6d2db427e722ada0cd7c9b1d30.tar.gz
As fork implementation of NetWare LibC still in experimental stages making the procve based solution ahead of HAVE_FORK. Later When fork becomes stable will revert this fix.
--Kamesh from hyanantha's account
-rw-r--r--ext/standard/proc_open.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index d38c3ba7ca..1f59725220 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -761,6 +761,46 @@ PHP_FUNCTION(proc_open)
child = pi.hProcess;
CloseHandle(pi.hThread);
+#elif defined(NETWARE)
+ if (cwd) {
+ orig_cwd = getcwd(NULL, PATH_MAX);
+ chdir2(cwd);
+ }
+ channel.infd = descriptors[0].childend;
+ channel.outfd = descriptors[1].childend;
+ channel.errfd = -1;
+ /* Duplicate the command as processing downwards will modify it*/
+ command_dup = strdup(command);
+ /* get a number of args */
+ construct_argc_argv(command_dup, NULL, &command_num_args, NULL);
+ child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*));
+ if(!child_argv) {
+ free(command_dup);
+ if (cwd && orig_cwd) {
+ chdir2(orig_cwd);
+ free(orig_cwd);
+ }
+ }
+ /* fill the child arg vector */
+ construct_argc_argv(command_dup, NULL, &command_num_args, child_argv);
+ child_argv[command_num_args] = NULL;
+ child = procve(child_argv[0], PROC_DETACHED|PROC_INHERIT_CWD, NULL, &channel, NULL, NULL, 0, NULL, (const char**)child_argv);
+ free(child_argv);
+ free(command_dup);
+ if (cwd && orig_cwd) {
+ chdir2(orig_cwd);
+ free(orig_cwd);
+ }
+ if (child < 0) {
+ /* failed to fork() */
+ /* clean up all the descriptors */
+ for (i = 0; i < ndesc; i++) {
+ close(descriptors[i].childend);
+ close(descriptors[i].parentend);
+ }
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "procve failed - %s", strerror(errno));
+ goto exit_fail;
+ }
#elif HAVE_FORK
/* the unix way */
child = fork();
@@ -831,46 +871,6 @@ PHP_FUNCTION(proc_open)
goto exit_fail;
}
-#elif defined(NETWARE)
- if (cwd) {
- orig_cwd = getcwd(NULL, PATH_MAX);
- chdir2(cwd);
- }
- channel.infd = descriptors[0].childend;
- channel.outfd = descriptors[1].childend;
- channel.errfd = -1;
- /* Duplicate the command as processing downwards will modify it*/
- command_dup = strdup(command);
- /* get a number of args */
- construct_argc_argv(command_dup, NULL, &command_num_args, NULL);
- child_argv = (char**) malloc((command_num_args + 1) * sizeof(char*));
- if(!child_argv) {
- free(command_dup);
- if (cwd && orig_cwd) {
- chdir2(orig_cwd);
- free(orig_cwd);
- }
- }
- /* fill the child arg vector */
- construct_argc_argv(command_dup, NULL, &command_num_args, child_argv);
- child_argv[command_num_args] = NULL;
- child = procve(child_argv[0], PROC_DETACHED|PROC_INHERIT_CWD, NULL, &channel, NULL, NULL, 0, NULL, (const char**)child_argv);
- free(child_argv);
- free(command_dup);
- if (cwd && orig_cwd) {
- chdir2(orig_cwd);
- free(orig_cwd);
- }
- if (child < 0) {
- /* failed to fork() */
- /* clean up all the descriptors */
- for (i = 0; i < ndesc; i++) {
- close(descriptors[i].childend);
- close(descriptors[i].parentend);
- }
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "procve failed - %s", strerror(errno));
- goto exit_fail;
- }
#else
# error You lose (configure should not have let you get here)
#endif