Return the return value of uv_spawn if not zero

Fixes #38
This commit is contained in:
Bob Weinand 2017-04-26 13:17:06 +02:00
parent db7ccff3cf
commit 2b5a298f82

View File

@ -5209,7 +5209,7 @@ PHP_FUNCTION(uv_spawn)
zval *zloop, *args, *env, *zoptions = NULL, *zstdio = NULL, *value; zval *zloop, *args, *env, *zoptions = NULL, *zstdio = NULL, *value;
char **command_args, **zenv; char **command_args, **zenv;
zend_string *command, *cwd; zend_string *command, *cwd;
int uid = 0, gid = 0, stdio_count = 0; int uid = 0, gid = 0, stdio_count = 0, ret;
long flags = 0; long flags = 0;
zend_fcall_info fci = empty_fcall_info; zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache; zend_fcall_info_cache fcc = empty_fcall_info_cache;
@ -5331,19 +5331,24 @@ PHP_FUNCTION(uv_spawn)
options.uid = uid; options.uid = uid;
options.gid = gid; options.gid = gid;
proc = (php_uv_t *)emalloc(sizeof(php_uv_t)); proc = (php_uv_t *) emalloc(sizeof(php_uv_t));
PHP_UV_INIT_ZVALS(proc); ret = uv_spawn(loop, &proc->uv.process, &options);
php_uv_cb_init(&cb, proc, &fci, &fcc, PHP_UV_PROC_CLOSE_CB);
TSRMLS_SET_CTX(proc->thread_ctx);
proc->type = IS_UV_PROCESS; if (ret) {
proc->uv.process.data = proc; efree(proc);
RETURN_LONG(ret);
} else {
PHP_UV_INIT_ZVALS(proc);
php_uv_cb_init(&cb, proc, &fci, &fcc, PHP_UV_PROC_CLOSE_CB);
TSRMLS_SET_CTX(proc->thread_ctx);
proc->resource_id = zend_register_resource(proc, uv_resource_handle); proc->type = IS_UV_PROCESS;
ZVAL_RES(return_value, proc->resource_id); proc->uv.process.data = proc;
zval_copy_ctor(return_value);
uv_spawn(loop, &proc->uv.process, &options); proc->resource_id = zend_register_resource(proc, uv_resource_handle);
ZVAL_RES(return_value, proc->resource_id);
zval_copy_ctor(return_value);
}
if (zenv != NULL) { if (zenv != NULL) {
char **p = zenv; char **p = zenv;