- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Trap in Korn shell scripts
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
тАО04-28-2005 12:31 AM
тАО04-28-2005 12:31 AM
I have a scheduled job which will run as follows,
script1 calles script2,script2 calls script3 and ends.
I opened an earlier thread where I mentioned someone (may be the OS or scheduler) is sending USR1 signals to some of the shell scripts.
So I placed a trap for script1 as ,
trap 'echo "Dont kill me"' USR1
This worked. But the subshells are still getting killed by the USR1's . Is there a away I can set a trap in a script which will be applicable for all the scripts that are triggered by that script?.
Regds,
Kaps
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 12:45 AM
тАО04-28-2005 12:45 AM
Re: Trap in Korn shell scripts
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 12:53 AM
тАО04-28-2005 12:53 AM
Re: Trap in Korn shell scripts
{ cm1 ; cm2; } --> subshells commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 12:53 AM
тАО04-28-2005 12:53 AM
Re: Trap in Korn shell scripts
Do you know why USR1's default action is terminate for a korn shell ? .
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 12:55 AM
тАО04-28-2005 12:55 AM
Re: Trap in Korn shell scripts
sh -c ""trap 'echo "Dont kill me"' USR1";sub_shell_command1;sub_shell_command2"
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 01:25 AM
тАО04-28-2005 01:25 AM
Re: Trap in Korn shell scripts
sh -c ""trap 'echo "Dont kill me"' USR1";sub_shell_comman1"
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 01:32 AM
тАО04-28-2005 01:32 AM
Re: Trap in Korn shell scripts
You need to find the source of the kill -SIGUSR1 commands. The operating system never does this automatically. Check all your cron jobs to find the culprit. There is nothing normal about kill -16 being sent to selected processes. NOTE: if kill -16 was sent to every process, your system would immediately crash or hang, so there is something selective about the kill signals. I would look for scripts that have kill commands, and rewrite any that use ps piped to grep. It is not very common to use SIGUSR1 (or SIGUSR2) so I suspect some local script writing is the problem.
> Do you know why USR1's default action is terminate for a korn shell ? .
Standard Unix behavior. See the man page for kill(1)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 06:07 AM
тАО04-28-2005 06:07 AM
Re: Trap in Korn shell scripts
> Do you know why USR1's default action is
> terminate for a korn shell ? .
Because SIGUSR1 (and SIGUSR2) are meant to be
user defined signals. System never sends those
signals. The intention is, if you are developing a
software that creates multiple processes and you
need to have a machanism for them to
communicate, you could use SIGUSR1 and
SIGUSR2. Typically, one of your process should
send the signal and the recipient should write a
handler that handles it. If you don't have a signal
handler but still receive those signals, the system
has no idea what to do. So killing the process is an
obvious choice for default action.
As others have already suggested, you need to
figureout who is sending you the SIGUSR1 and
why?
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2005 11:46 PM