note 105899 added to function.call-user-func
| From: | Gavin at osu1 dot php dot net | Date: | Fri, 23 Sep 2011 21:48:30 +0000 |
| Subject: | note 105899 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183397@lists.php.net to get a copy of this message | ||
If using call_user_func() to pass resources (e.g. pipes created by proc_open), pass them using an
array or object containing the resources, instead of "naked".
Bad: call_user_func($callback, $pipes[0], $pipes[1], $pipe[2]);
Good: Bad: call_user_func($callback, $pipes);
Passing the variables containing resource ids in the "bad" example above appears to work,
but can cause troubles later when trying to close STDIN ($pipe[0] for example), and then read the
output of the spawned child from $pipes[1]. The child process may or may not hang in read(), as
reported by strace, even though the passed resources look valid, and the fclose on the stdin
resource returns true.
Switching to the "good" example above solved the issue above for me.
Peace to you.
----
Server IP: 69.147.83.197
Probable Submitter: 69.107.96.6
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit -- https://master.php.net/note/edit/105899
Del: integrated -- https://master.php.net/note/delete/105899/integrated
Del: useless -- https://master.php.net/note/delete/105899/useless
Del: bad code -- https://master.php.net/note/delete/105899/bad+code
Del: spam -- https://master.php.net/note/delete/105899/spam
Del: non-english -- https://master.php.net/note/delete/105899/non-english
Del: in docs -- https://master.php.net/note/delete/105899/in+docs
Del: other reasons-- https://master.php.net/note/delete/105899
Reject -- https://master.php.net/note/reject/105899
Search -- https://master.php.net/manage/user-notes.php