- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- function used to create background task hangs on e...
Operating System - HP-UX
1820475
Members
3051
Online
109624
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2002 07:34 AM
тАО07-09-2002 07:34 AM
I created a ksh script "x" which calls a function "dwit". dwit creates several background tasks using:
nohup /cpf/bin/fms &
When I execute dwit in the following formats it works:
dwit
dwit > log
dwit >log 2>&1
When I use the |tee command:
dwit |tee log
dwit 2>&1 |tee log
dwit |tee log 2>&1
the dwit command hangs after executing the last command which is "exit".
I have to stop the "x" script with a ctrl-c.
I have removed the background creation from dwit and the process works fine, so the problem is related to background and |tee.
nohup /cpf/bin/fms &
When I execute dwit in the following formats it works:
dwit
dwit > log
dwit >log 2>&1
When I use the |tee command:
dwit |tee log
dwit 2>&1 |tee log
dwit |tee log 2>&1
the dwit command hangs after executing the last command which is "exit".
I have to stop the "x" script with a ctrl-c.
I have removed the background creation from dwit and the process works fine, so the problem is related to background and |tee.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2002 10:34 PM
тАО07-09-2002 10:34 PM
Solution
Hi
If tee hangs try script
script file
dwit
exit
Everything that happens goes to the file in copy.
The tee hang is probably caused by this.
Any process's children inherit the parent's open file descriptors. If the child does not close any them they stay open until the process exits and will be passed to
their children in a similar mannor.
A pipe, does not deliver an end-of-file indicator to its reading end until all processes that have opened it for writing have closed their file descriptors.
Thus tee, or any other command using the pipe in a comparable way,
will not terminate until all descendents of the process that inherited the pipe as the standard output have closed it or terminated.
During a hang, the program lsof may be used to
determine which processes have the pipe open for reading or writing.
Also checking the output from a ps command will show processes that are running.
Steve Steel
If tee hangs try script
script file
dwit
exit
Everything that happens goes to the file in copy.
The tee hang is probably caused by this.
Any process's children inherit the parent's open file descriptors. If the child does not close any them they stay open until the process exits and will be passed to
their children in a similar mannor.
A pipe, does not deliver an end-of-file indicator to its reading end until all processes that have opened it for writing have closed their file descriptors.
Thus tee, or any other command using the pipe in a comparable way,
will not terminate until all descendents of the process that inherited the pipe as the standard output have closed it or terminated.
During a hang, the program lsof may be used to
determine which processes have the pipe open for reading or writing.
Also checking the output from a ps command will show processes that are running.
Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2002 10:49 PM
тАО07-09-2002 10:49 PM
Re: function used to create background task hangs on exit when |tee present
Hi Randy,
if your function dwit is the last command line in your script then try to call it like this:
script_name | tee log 2>&1
this should do it for you.
Allways stay on the bright side of life!
Peter
if your function dwit is the last command line in your script then try to call it like this:
script_name | tee log 2>&1
this should do it for you.
Allways stay on the bright side of life!
Peter
I'm learning here as well as helping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-10-2002 06:09 AM
тАО07-10-2002 06:09 AM
Re: function used to create background task hangs on exit when |tee present
Steve, your clarification of my problem enabled me to fix it.
The tasks I start from the function "dwit" run continuously until a system reboot or I kill them manually, therefore they don't close output to the pipe.
The solution:
dwit now initiates the tasks as:
nohup task >tasklog 2>&1 &
by redirecting the child task's output to tasklog the pipe closes.
thanks.
The tasks I start from the function "dwit" run continuously until a system reboot or I kill them manually, therefore they don't close output to the pipe.
The solution:
dwit now initiates the tasks as:
nohup task >tasklog 2>&1 &
by redirecting the child task's output to tasklog the pipe closes.
thanks.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP