LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices



Reply
 
Search this Thread
Old 12-18-2013, 10:22 AM   #1
shubert_doug
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
bash hangs on tee(1) in pipeline


A small application of mine uses tee(1) in pipelines a lot to log the output of subshells. it very often hangs leaving a zombie process that is the parent of a tee(1) process. The ps -aef output for the tee(1) generally looks like this:
dougl 11469284 12517574 0 14:07:43 pts/8 0:00 tee /tmp//sh-np-4134995703

Typical use in this scenario is from within a function:
"${@}" 2>&1 | tee >(sed -n -e "s/^/${timestamp} ${caller} #### /g" -ep 2>&1 >> ${iss_log_file}) | (printf "${caller} " ; cat -)

The "${@}" are the args to the function and very often a pipeline itself.

Has anyone else experienced this? Is there a "natural" fix? (Think shell environment, configuration, or the like. Spawning a coprocess to keep an eye on such things is certainly possible, but seems wrong somehow.)

I'm on AIX 6.1. Bash is version 4.2.1.

Thanks.

,Doug
 
Old 12-18-2013, 10:36 AM   #2
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,169

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
one thing I can see is the handling of stderr:
this would be better I think:
(sed -n -e "s/^/${timestamp} ${caller} #### /g" -ep >> ${iss_log_file} 2>&1 )
or you can try:
exec 2>&1
before this line (if it was made in a function)
 
Old 12-18-2013, 10:52 AM   #3
shubert_doug
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Well, darn! Now I have to look closely at that use of stderr again.

There are cases where the calling function does want error output too.

Thanks.

Tick. Tick. Tick.

I'm back; I've looked. This is indeed one of those cases. Thanks for the critical eye.

Last edited by shubert_doug; 12-18-2013 at 10:54 AM.
 
Old 12-18-2013, 10:55 AM   #4
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,169

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
this is not about stderr, but the order of the evaluation of redirections.
http://www.tldp.org/LDP/abs/html/io-redirection.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List all alternatives to encrypt data (for bash /pipeline)? frenchn00b Programming 0 01-06-2009 10:48 AM
noob Pipeline help. promero Programming 8 09-11-2005 04:42 PM
bash hangs on waitpid mg2 Linux - Software 1 04-18-2005 04:10 AM
pipeline buffering jk3us Linux - Software 2 12-17-2004 08:52 PM
pipeline using rm verstapp Linux - General 3 03-09-2004 12:33 AM


All times are GMT -5. The time now is 08:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration