php-general Digest 20 Jan 2012 17:15:58 -0000 Issue 7658
Topics (messages 316342 through 316344):
Re: pcntl_fork, catching STDOUT of child?
316342 by: FeIn
Considering segfaults: how to protect other requests?
316343 by: KÄrlis Repsons
Settings to Allow Precise File Upload Bytes
316344 by: Dee Ayy
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Have a look at zeromq.
http://vimeo.com/20605470
http://zguide.zeromq.org/php:all
Hope it helps.
On Fri, Jan 20, 2012 at 12:24 AM, Thomas Johnson <[email protected]> wrote:
> Hello,
>
> PHP noob here. I've been working on writing a script (command-line) that
> forks a number of children to do various tasks. I've been using
> pcntl_waitpid inside a loop to wait for the children to exit, act on the
> results, and fork another copy of the child. Where I seem to be running
> into trouble is in managing communication between child and parent, so that
> the parent has an indication of result inside the child.
>
> In the past, I've done this in Perl using something along the lines of:
>
> open(FILEHANDLE,"-|");
>
> In Perl, this has the effect of forking the process and attaching the
> STDOUT of the child to FILEHANDLE on the parent. Thus, when the child
> exits, I read FILEHANDLE to get the output from the child.
>
> Is there a similar way of achieving a similar result in PHP? Am I crazy? So
> far, I have tried to communicate between the processes using sockets
> (socket_create_pair). However, this seems to be a dead-end, I get a
> "connection reset by peer" when I try to socket_read() from the parent. I
> assume this is because the socket is closed by the exit of the child.
>
> Any insight or criticism is appreciated.
>
> --
> Thomas Johnson
> ClaimLynx, Inc. <952-593-5969%20x2302>
>
--- End Message ---
--- Begin Message ---
Hi there...
Perhaps some of you could advise about this:
using apache2 prefork, I've confirmed that the same PHP extension can
receive multiple requests through browser and if one of those requests
causes a segfault, the other request, which is still in process during the
segfault, will be completed. Good... But how to be sure if this is just a
particular case or there is some way to know that ONLY those requests
will get terminated and not be completed, which are themselves causing
a segfault? Or make it that way?
Thanks...
--- End Message ---
--- Begin Message ---
Please advise the proper settings (Apache/PHP/HTML/MySQL/Anything else
I missed) to allow a specific byte size upload and to deny 1 byte over
with error reporting in LAMP/AJAX. I've heard of Flash and Gears
solutions, but these require additional installs for the user -- just
to know the file size before an upload.
The server is Apache 2.
PHP is 5.1.6
HTML has
<!DOCTYPE html>
<input type="hidden" name="MAX_FILE_SIZE" value="1030000" />
<input type="file" name="attachment" />
PHP ini :
file_uploads On On
upload_max_filesize 2M 2M
post_max_size 8M 8M
I believe MySQL max_allowed_packet 1,048,576 was affecting the MySQL
INSERT, so I changed MAX_FILE_SIZE to 1030000 above.
Now I am seeing cases where
if(isset($_FILES['attachment']) && $_FILES['attachment']['size'] > 0){
evaluates to FALSE
How can I know that a file upload was attempted yet failed or will fail?
My last test case had the web page still claiming it was busy, yet I
noticed that the above condition must have evaluated to FALSE, failing
silently due to missing error reporting on my part (or the system's
part).
I am willing to make 2 requests:
1) just to find out if the attempted upload will fail and inform the user.
2) for the actual upload if it should succeed.
TIA
--- End Message ---