On Thu, November 30, 2006 8:41 am, Jochem Maas wrote: > hi Richard, > > Richard Lynch wrote: >> On Tue, November 28, 2006 7:25 am, Jochem Maas wrote: >>> so the question is how can I use readline() and handle the SIGINT >>> gracefully whilst not waiting >>> for readline() to return control to my script? >> >> I'm just guessing here, but you probably don't. > > I guess so too. would you consider it a bug that php defers the > processing of system signals whilst readline() is waiting to return > control to the script? and what is the likelihood that this has > anything > to do with php? if it is down to the readline extension itself I would > be surprised - I would have expected a lib like GNU's readline to take > account of signals and handle them correctly/gracefully. >From the outside looking in, it seems like it shouldn't do that... My first guess is that it has to for some geeky reason that would take me weeks and weeks to figure out, assuming I could even manage to read that C source at all. But it's entirely possible that it's just a silly simple mistake/oversight down in the guts of PHP somewhere. A query to PHP-DEV list followed up by a well-written bug report would probably take care of that, if it's the case. >> You could, howver, write your own PHP function similar to readline, >> only without whatever is in readline that ignores/buffers signals. >> >> You'd want something like an fread($x, 1) on a non-blocking stream, >> and then build up the string character by character, until you get a >> newline. > > I can live with it the way it is - having followed your battle with > non-blocking > madness in various threads in the past I don't feel much for diving > into that > abyss myself (it doesn't help that my undertstanding of streams is > patchy at best!) Keep in mind that my understanding of streams is no better than yours! I do know that the trick is to use ini_set() to change the timeout of a stream connection to 0, so it won't block on connection. My attempts to add that to User Contributed Notes were rebuffed, however, so I don't see any good way to document it with the stream_set_blocking function where every newbie always looks for it. PS For most of a decade, finding more time to mess with the PHP source and try to contribute something useful has been on my "To Do" list... Sigh. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php