The whole picture is that i want to control a child process completely from within php. A bit like popen or proc_open but with 2 independent pipes to the child's stdin and stdout that I can read and write to. So I'm basically wrapping the c functions pipe(), dup2() and friends. Once I have it all working I will offer to add the functions into the pcntl extension if they're wanted.
Anyway the code in the pipe function that was giving me the warnings is as follows: PHP_FUNCTION(pipe) { pipe_r_le_struct *st_pipe_r; pipe_w_le_struct *st_pipe_w; zval *read; zval *write; int pipe_fd[2]; if( pipe(pipe_fd ) <0 ){ php_error( E_ERROR, "Could not create pipe" ); } st_pipe_r = emalloc( sizeof( pipe_r_le_struct ) ); st_pipe_w = emalloc( sizeof( pipe_w_le_struct ) ); st_pipe_r->fd = pipe_fd[0]; st_pipe_w->fd = pipe_fd[1]; MAKE_STD_ZVAL( read ); MAKE_STD_ZVAL( write ); ZEND_REGISTER_RESOURCE( read, st_pipe_r, le_pipe_r ) ZEND_REGISTER_RESOURCE( write, st_pipe_w, le_pipe_w ) array_init( return_value ); add_assoc_resource( return_value, "read", Z_RESVAL_P( read ) ); add_assoc_resource( return_value, "write", Z_RESVAL_P( write ) ); } If i use FREE_ZVAL() at the end of this function I can get rid of the warnings but I would guess this is the wrong place and it should be taken care of in a cleanup function when the request has finished. Please excuse me if I am missing something obvious here, as you may guess I'm still finding my feet writing PHP extensions. Tony On Sat, 2002-11-09 at 08:56, Andi Gutmans wrote: > Actually zval_ptr_dtor() is probably more suitable. > In any case, is this zval something you keep locally in your extension or > are you returning/adding it to the engine's symbol table? If so, the engine > should take care of the memory automatically as long as you've done > everything correctly. > Maybe you should explain in more detail what you're doing. > Andi > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php