- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Back ground process killed on using Ctrl-C
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
06-29-2009 02:25 AM
06-29-2009 02:25 AM
I have this menu driven script of mine,which i have written on bash shell.There is this option on my menu where i start 2 set of process in the background.Now when i choose the proper exit option from my menu,i dont encounter any problems.But the moment i press Ctrl-C , these background processes get killed.I have tried a lots of option like nohup,onintr,trap,and even tried wrapping my executable call in csh so that the background process does not get the interrupt signal.I also ran through the HP UX manual ,but that dint help me much.Kindly help me in solving this issue.....
Solved! Go to Solution.
- Tags:
- SIGINT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 02:40 AM
06-29-2009 02:40 AM
SolutionProcess management in Posix/HP-UX is different than bash.
http://docs.hp.com/en/5965-4642/5965-4642.pdf
Posix asynchronous I/O (maybe not related.
http://docs.hp.com/en/B9106-90012/ix01.html
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 03:11 AM
06-29-2009 03:11 AM
Re: Back ground process killed on using Ctrl-C
Have you tried using a real shell?
>But the moment I press Control-C, these background processes get killed.
I suppose you could write a SIGINT handler.
>I have tried a lots of option like nohup
I guess that only handles SIGHUP.
If you look at termio(7), it says:
Generates a SIGINT signal which is sent to all processes in the foreground process group for which the terminal is the controlling terminal.
I would have thought that excluded your background processes. But you may have to change them to demons so they aren't affected by the control-C.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 03:22 AM
06-29-2009 03:22 AM
Re: Back ground process killed on using Ctrl-C
So what exaclty do u say i do to get this problem solved.I want this process to be started through my script itself.Should i change the shell that i am working on,would that help me ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 03:37 AM
06-29-2009 03:37 AM
Re: Back ground process killed on using Ctrl-C
> So what exaclty do u say i do to get this problem solved
I would change your script to use the Posix shell and verify that the behavior you want is achieved (it should be). This may be the simplest solution and brings your script in line with HP-UX standards, too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 04:07 AM
06-29-2009 04:07 AM
Re: Back ground process killed on using Ctrl-C
It might be helpful if you could decompose your script into a small one that fails in your hands and then post that here. I cannot reproduce your problem on a Linux box (for what that's worth).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 04:16 AM
06-29-2009 04:16 AM
Re: Back ground process killed on using Ctrl-C
I assume you are redirecting stdout and stderr. Are you redirecting stdin to /dev/null?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 06:23 AM
06-29-2009 06:23 AM
Re: Back ground process killed on using Ctrl-C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 06:48 AM
06-29-2009 06:48 AM
Re: Back ground process killed on using Ctrl-C
A simple test case is preferred. That said, this statement:
# nohup TradexLocMon trdxdev 2 2 & >>/dev/null
...should probably be:
# nohup TradexLocMon trdxdev 2 >/dev/null 2>&1 &
...which says to run 'TradeexLocMon' as a hangup immune process in the background, passing two arguments ("trdxdev" and "2"). Redirect any STDOUT and STDERR to '/dev/null'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 08:15 AM
06-29-2009 08:15 AM
Re: Back ground process killed on using Ctrl-C
Perhaps I misunderstood. You said that your last attachment was ..."the script that i call from my option ...".
To start _that_ script in the background you would want to call it as I showed; something like:
# nohup /oath_to_script arg1 arg2 arg3 < /path_to_input > /path_to_output 2>&1 &
The '/path_to_input' and/or '/
path_to_output' can be '/dev/null; if necessary.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 08:38 AM
06-29-2009 08:38 AM
Re: Back ground process killed on using Ctrl-C
From the links I posted for you.
nohup script_name &
That will background the processes run them in the background.
Output will go to a nohup.out file
You can with HP-UX use the equivalent of strace (fron Linux), called tusc to trace your process and get specific actions and error codes.
tusc: http://hpux.connect.org.uk/hppd/hpux/Sysadmin/tusc-7.10/
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 08:46 AM
06-29-2009 08:46 AM
Re: Back ground process killed on using Ctrl-C
yes i have 3 args bck here ....trdxdev,2,2
I tried the below part too...
#nohup TradexLocMon trdxdev 2 2 >/dev/null 2>&1 &
It doesnt seem to work ...could i use "onintr -" to ignore all signals ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 08:54 AM
06-29-2009 08:54 AM
Re: Back ground process killed on using Ctrl-C
...i dont have "tusc" installed on my server...Is ther any other way that i could track the process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 11:23 AM
06-29-2009 11:23 AM
Re: Back ground process killed on using Ctrl-C
No, you need to install tusc.
(Have you tried redirecting stdin to /dev/null?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 11:35 AM
06-29-2009 11:35 AM
Re: Back ground process killed on using Ctrl-C
With a (last)name like yours I would not have expected you to use bash. If you stuck to your name you would have ended up with the good old sh which is replaced by posix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 11:50 AM
06-29-2009 11:50 AM
Re: Back ground process killed on using Ctrl-C
I install tusc on all my servers.
This is not Linux. You need to add many tools that you would find by default on Linux.
tusc is a basic tool that you should install to track this process.
I 100% back what Dennis says to you.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2009 01:39 AM
08-31-2009 01:39 AM
Re: Back ground process killed on using Ctrl-C
I have attached my script here below.Please help me on this.Is the shell that i am executing this script a major problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2009 04:28 AM
08-31-2009 04:28 AM
Re: Back ground process killed on using Ctrl-C
> Havnt been able to crack this one yet though.
As I originally said, it would be much better to decompose your failing script into it's simplest case.
Did you try any of the changes suggested? Did you try using a pure POSIX shell? Why would you want to mix into this a crummy C-shell?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2009 11:04 PM
08-31-2009 11:04 PM
Re: Back ground process killed on using Ctrl-C
Thnx for the reply.Yes i tried lots of things but nothing seems to work .
>Did you try using a pure POSIX shell
Do u say i use sh shell instead of the bash shell.If so how will that differ.I have tried that too.Dint go thru...
>Why would you want to mix into this a crummy C-shell?
Well we have two set of servers here.Linux and HP-UX.I was initially trying to crack this issue on the linux machine and happpend to find that my process was getting killed bcoz the bash shell had a drawback ,where in it is unable to handle an interrupt signal.Thereby killing the background process initiated within.Thus i used the Csh which handled the interrupt signal...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2009 11:34 PM
08-31-2009 11:34 PM
Re: Back ground process killed on using Ctrl-C
itrc_background.sh:
#!/usr/bin/sh
# start a background shell and try blocking Control-C
itrc_background.2.sh &
sleep 60
itrc_background.2.sh:
#!/usr/bin/sh
echo "got to $0"
sleep 30
echo "finished with $0"
When I invoke itrc_background.sh, it starts itrc_background.2.sh. If I type Control-C, only itrc_background.sh is killed, itrc_background.2.sh keeps sleeping.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2009 04:20 AM
09-09-2009 04:20 AM
Re: Back ground process killed on using Ctrl-C
Yes i did try this out... But wat i see is when Control-C is pressed, the sleep continues in the background but the process still dies out ...Why is this so ...
Is there anyway is could make the process neglect this interrupt signal like by using something like trap or omintr ...Would changing this help me in any manner ...
Thnx for ur reply ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2009 04:28 AM
09-09-2009 04:28 AM
Re: Back ground process killed on using Ctrl-C
The sleep continues and then it echoes the message after sleep. So that case works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2009 04:37 AM
09-09-2009 04:37 AM
Re: Back ground process killed on using Ctrl-C
Look mine being a menu driven script i need to continue one activty after the other.So what i did was ,i calld this script in the background, which first starts the process in the background and then the sleep of arnd 30 sec in the background.
On doin so i happend to see that when both sleep and my process are running in the background and if i press Control-C , the sleep still continues, but the process dies out.
Hope you understand what i mean ...
Thnx for the reply ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2009 12:52 AM
09-10-2009 12:52 AM
Re: Back ground process killed on using Ctrl-C
I thought I did but my small example works fine.
Here is where tusc can help you find what's different in your case and my small example.
Did you ever try redirecting stdin to /dev/null?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2009 02:35 AM
09-10-2009 02:35 AM
Re: Back ground process killed on using Ctrl-C
> Here is where tusc can help you find what's different in your case
Yes i know but i have a problem here.I dont have tusc installed on my server and installing it aint that easy with all the restrictions applied...(but iam still working on getting it installed).Can i use tusc for all versions of HP-Ux ???
>redirecting stdin
Yes i tried that out too ...
If my executable name is :TradexLocMon
arguments are : 2 and 2
then redirecting it to dev/null would be like this rite..
#TradexLocMon trdxdev 2 2 & 0>/dev/null
Well this dint work either :(
Its that the sleep process doesnt seem to have any problem with the interrupt signal ...Just that my process simply wont stay arnd at that time ;)
Thnx for the reply ....