diff options
author | Thies C. Arntzen <thies@php.net> | 2001-01-10 13:08:14 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 2001-01-10 13:08:14 +0000 |
commit | 6871b839b554bb86679e3c24a2baf1e1e7a4a7fd (patch) | |
tree | be7f09010f15a0947ed9478376fbd77a537ffbd2 /ext/standard/exec.c | |
parent | 2b3d9d7ec454ea8d573158bc90970c58000718f6 (diff) | |
download | php-git-6871b839b554bb86679e3c24a2baf1e1e7a4a7fd.tar.gz |
exec'd processes now get cleaned up even if the browser connections was
aborted.
fixes: #8143
Diffstat (limited to 'ext/standard/exec.c')
-rw-r--r-- | ext/standard/exec.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 88a0888ee0..d1d4959ea1 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -23,6 +23,7 @@ #include "php_string.h" #include "safe_mode.h" #include "ext/standard/head.h" +#include "ext/standard/file.h" #include "exec.h" #include "php_globals.h" #include "SAPI.h" @@ -45,6 +46,7 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) int buflen = 0; int t, l, ret, output=1; int overflow_limit, lcmd, ldir; + int rsrc_id; char *b, *c, *d=NULL; PLS_FETCH(); @@ -116,6 +118,13 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) array_init(array); } } + + /* we register the resource so that case of an aborted connection the + * fd gets pclosed + */ + + rsrc_id = ZEND_REGISTER_RESOURCE(NULL, fp, php_file_le_fopen()); + if (type != 3) { l=0; while ( !feof(fp) || l != 0 ) { @@ -183,8 +192,10 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value) if (output) (void)PUTC(buf[i]); } } + + /* the zend_list_delete will pclose our popen'ed process */ + zend_list_delete(rsrc_id); - ret = pclose(fp); #if HAVE_SYS_WAIT_H if (WIFEXITED(ret)) { ret = WEXITSTATUS(ret); |