[sf-perl] [ot?] no pipe for you

David Alban extasia at extasia.org
Tue Sep 18 14:32:10 PDT 2012


greetings,

a user said that one of my perl library routines that does sudo
commands was hanging.  the user was using the routine to restart a
system service (i.e., invoke an /etc/init.d script via /sbin/service).

i started poking and it was hanging in my routine at the line:

  @results = qx{ $command 2>&1 };

we've used this routine for a few years without anything like this happening.

so i poke some more and found that all of these act "normally":

  $ sudo service foo restart
  $ sudo service foo stop
  $ sudo service foo start
  $ sudo bash -xv /etc/init.d/foo stop 2>&1 | tee junk

but...  these do their actions successfully (start and restart) and
then subsequently fail to return the command prompt (i.e., hang):

  $ sudo bash -xv /etc/init.d/foo start 2>&1 | tee junk
  $ sudo bash -xv /etc/init.d/foo restart 2>&1 | tee junk

these "hang", too:

  $ sudo service wso2am start 2>&1 | tee ~/junk
  $ sudo service wso2am restart 2>&1 | tee ~/junk

i remember discovering that the ps command behaves different if its
output goes to a pipe (it doesn't truncate the output at the edge of
your screen), but might anyone here have an idea about why the start
and restart hang when their output it going to a pipe?

wierd.

thanks,
david
-- 
Live in a world of your own, but always welcome visitors.
***
Rule of law is for the little people.
http://www.amazon.com/Liberty-Justice-Some-Equality-Powerful/dp/0805092056


More information about the SanFrancisco-pm mailing list