Operating System - HP-UX
1753848 Members
8110 Online
108807 Solutions
New Discussion юеВ

Back ground process killed on using Ctrl-C

 
SOLVED
Go to solution
Jason bourne_2
Occasional Advisor

Back ground process killed on using Ctrl-C

Hi,
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.....
26 REPLIES 26
Steven E. Protter
Exalted Contributor
Solution

Re: Back ground process killed on using Ctrl-C

Shalom,

Process 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
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dennis Handly
Acclaimed Contributor

Re: Back ground process killed on using Ctrl-C

>I have written on bash shell.

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.
Jason bourne_2
Occasional Advisor

Re: Back ground process killed on using Ctrl-C

Hi Steven,
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 ...
James R. Ferguson
Acclaimed Contributor

Re: Back ground process killed on using Ctrl-C

Hi Jason:

> 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...
James R. Ferguson
Acclaimed Contributor

Re: Back ground process killed on using Ctrl-C

Hi (again) Jason:

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...
Dennis Handly
Acclaimed Contributor

Re: Back ground process killed on using Ctrl-C

>where I start 2 set of process in the background.

I assume you are redirecting stdout and stderr. Are you redirecting stdin to /dev/null?
Jason bourne_2
Occasional Advisor

Re: Back ground process killed on using Ctrl-C

This is the script that i call from my option ...
James R. Ferguson
Acclaimed Contributor

Re: Back ground process killed on using Ctrl-C

Hi Jason:

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...
James R. Ferguson
Acclaimed Contributor

Re: Back ground process killed on using Ctrl-C

Hi (again) Jason:

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...