LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 09: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, 09:36 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
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, 09: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 09:54 AM.
 
Old 12-18-2013, 09:55 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

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


Reply



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 09:48 AM
noob Pipeline help. promero Programming 8 09-11-2005 03:42 PM
bash hangs on waitpid mg2 Linux - Software 1 04-18-2005 03:10 AM
pipeline buffering jk3us Linux - Software 2 12-17-2004 07:52 PM
pipeline using rm verstapp Linux - General 3 03-08-2004 11:33 PM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 11:27 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
Open Source Consulting | Domain Registration