Lines Matching refs:proc
239 static pid_t waitpid_cached(php_process_handle *proc, int *wait_status, int options) in waitpid_cached() argument
241 if (proc->has_cached_exit_wait_status) { in waitpid_cached()
242 *wait_status = proc->cached_exit_wait_status_value; in waitpid_cached()
243 return proc->child; in waitpid_cached()
246 pid_t wait_pid = waitpid(proc->child, wait_status, options); in waitpid_cached()
252 proc->has_cached_exit_wait_status = true; in waitpid_cached()
253 proc->cached_exit_wait_status_value = *wait_status; in waitpid_cached()
265 php_process_handle *proc = (php_process_handle*)rsrc->ptr; in proc_open_rsrc_dtor() local
275 for (int i = 0; i < proc->npipes; i++) { in proc_open_rsrc_dtor()
276 if (proc->pipes[i] != NULL) { in proc_open_rsrc_dtor()
277 GC_DELREF(proc->pipes[i]); in proc_open_rsrc_dtor()
278 zend_list_close(proc->pipes[i]); in proc_open_rsrc_dtor()
279 proc->pipes[i] = NULL; in proc_open_rsrc_dtor()
289 WaitForSingleObject(proc->childHandle, INFINITE); in proc_open_rsrc_dtor()
291 GetExitCodeProcess(proc->childHandle, &wstatus); in proc_open_rsrc_dtor()
297 CloseHandle(proc->childHandle); in proc_open_rsrc_dtor()
304 wait_pid = waitpid_cached(proc, &wstatus, waitpid_options); in proc_open_rsrc_dtor()
320 _php_free_envp(proc->env); in proc_open_rsrc_dtor()
321 efree(proc->pipes); in proc_open_rsrc_dtor()
322 zend_string_release_ex(proc->command, false); in proc_open_rsrc_dtor()
323 efree(proc); in proc_open_rsrc_dtor()
340 php_process_handle *proc; in PHP_FUNCTION() local
349 proc = (php_process_handle*)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open); in PHP_FUNCTION()
350 if (proc == NULL) { in PHP_FUNCTION()
355 RETURN_BOOL(TerminateProcess(proc->childHandle, 255)); in PHP_FUNCTION()
357 RETURN_BOOL(kill(proc->child, sig_no) == 0); in PHP_FUNCTION()
366 php_process_handle *proc; in PHP_FUNCTION() local
372 proc = (php_process_handle*)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open); in PHP_FUNCTION()
373 if (proc == NULL) { in PHP_FUNCTION()
388 php_process_handle *proc; in PHP_FUNCTION() local
402 proc = (php_process_handle*)zend_fetch_resource(Z_RES_P(zproc), "process", le_proc_open); in PHP_FUNCTION()
403 if (proc == NULL) { in PHP_FUNCTION()
408 add_assoc_str(return_value, "command", zend_string_copy(proc->command)); in PHP_FUNCTION()
409 add_assoc_long(return_value, "pid", (zend_long)proc->child); in PHP_FUNCTION()
412 GetExitCodeProcess(proc->childHandle, &wstatus); in PHP_FUNCTION()
421 wait_pid = waitpid_cached(proc, &wstatus, WNOHANG|WUNTRACED); in PHP_FUNCTION()
423 if (wait_pid == proc->child) { in PHP_FUNCTION()
443 add_assoc_bool(return_value, "cached", proc->has_cached_exit_wait_status); in PHP_FUNCTION()
1175 php_process_handle *proc; in PHP_FUNCTION() local
1413 proc = (php_process_handle*) emalloc(sizeof(php_process_handle)); in PHP_FUNCTION()
1414 proc->command = zend_string_copy(command_str); in PHP_FUNCTION()
1415 proc->pipes = emalloc(sizeof(zend_resource *) * ndesc); in PHP_FUNCTION()
1416 proc->npipes = ndesc; in PHP_FUNCTION()
1417 proc->child = child; in PHP_FUNCTION()
1419 proc->childHandle = childHandle; in PHP_FUNCTION()
1421 proc->env = env; in PHP_FUNCTION()
1423 proc->has_cached_exit_wait_status = false; in PHP_FUNCTION()
1466 proc->pipes[i] = NULL; in PHP_FUNCTION()
1478 proc->pipes[i] = Z_RES(retfp); in PHP_FUNCTION()
1484 RETVAL_RES(zend_register_resource(proc, le_proc_open)); in PHP_FUNCTION()