no_gravity no_gravity - 1 year ago 66
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)

Answer Source

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

xclip doesn't close the STDOUT.

related to: this questions answer

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download