- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ^C signal trap problem.
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
Forums
Discussions
Discussions
Discussions
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
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
01-04-2002 08:32 AM
01-04-2002 08:32 AM
My requiremnet is when i press ^c during Menu based child script execution i do not want parent to get killed it is only child which should get killed and i should be able to return back to main menu. I have used following code to acheive this purpous.
Parent Script
---------------
#!/bin/ksh
trap "" 2
Child script called from this menu
child script
-----------------
#!/bin/ksh
trap 2 #untrap ^c signal
tail -f "Some file name"
But i am not able to acheive this i can not come out of tail -f command by pressing ^c key. I will appreciate if somebody can correct me.
Regards
Rajeev
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 08:49 AM
01-04-2002 08:49 AM
Re: ^C signal trap problem.
#!/bin/ksh
trap "" 2
code
...
code
trap 2
child_script.sh
trap "" 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 08:51 AM
01-04-2002 08:51 AM
SolutionC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 08:55 AM
01-04-2002 08:55 AM
Re: ^C signal trap problem.
Jeff is correct. Excerpt from man sh-posix:-
Any attempt to set a trap on a signal that was ignored upon entering the current shell is ineffective.
Your parent shell ignores signal 2 so the child will too!
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 08:58 AM
01-04-2002 08:58 AM
Re: ^C signal trap problem.
trap "" 2
. child.sh
####### child.sh #######
trap 2
tail file
the trap will be gone, but the interrupt will hit the parent first
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 09:12 AM
01-04-2002 09:12 AM
Re: ^C signal trap problem.
thanks for your valuable replies. My problem got solved i did something like this in child.
trap "kill -9 `ps -ef | grep $$| grep -v grep | awk '$3=='$$'{print $2}'" 2
and it worked.
Once again thanks to you all and wish you all a very happy new year.
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2002 04:33 AM
01-07-2002 04:33 AM
Re: ^C signal trap problem.
In the parent script, ignore signal 2 by executing a dummy function:
#!/usr/bin/sh
function ignoreit {
return
}
trap "ignoreit" 2
Call child etc
Child script
===========
#!/usr/bin/sh
trap 2
tail -f ...
Regards,
John