no_gravity no_gravity - 5 months ago 33
Bash Question

passthru hangs if the executed command writes to the clipboard

Put this in a file "a.php" and execute it. It works just fine:

$p = popen('xclip -i -selection clipboard', 'w');
fwrite($p, 'Hello Word');

Now make a file "b.php" and execute it:


It hangs forever. Why?

(If you do not have xclip, you can install it with apt-get install xclip)


"xclip -i -selection clipboard > /dev/null" should fix it

xclip doesn't close the STDOUT.

related to: this questions answer