Reputation: 1110
The following minimal testcase gives this output:
string(3) "foo"
Warning: stat() [function.stat]: stat failed for Resource id #3 in /[...]/mkfifo.php on line 10
bool(false)
<?php
$pipe_name = 'foo';
if(!file_exists($pipe_name) && !posix_mkfifo($pipe_name, 0777)){
echo 'foo';
exit(1);
}
var_dump($pipe_name);
$pipe = fopen($pipe_name, 'r+');
var_dump(stat($pipe));
?>
Surely I'm doing something wrong? I used r+ because it's supposedly "works for me" per http://php.net/manual/en/function.posix-mkfifo.php#89642 but as you can see I don't even get a chance to do the non-blocking part. Alternative, more verbose solution that I haven't tried yet: http://php.net/manual/en/function.shell-exec.php#52826
Upvotes: 0
Views: 3298
Reputation: 145482
I think your error is soleley caused by using stat()
there. You give it an opened file resource, but it should be used with a $filename
only.
Your pipe was correctly opened as evidenced by Resource id #3
Use stat($pipe_name)
to get informations about the fifo.
Or stream_get_meta_data($pipe)
for the opened file handle.
Upvotes: 3