Main Page | Report this Page
Linux Forum Index  »  Linux Development - System  »  ^C does not work on application processes...
Page 1 of 1    

^C does not work on application processes...

Author Message
zix...
Posted: Sat Oct 10, 2009 4:19 am
Guest
Hi, I am working on a customised shell. I have been disabling/enabling
(SIGINT) signals on some conditions. I am finding ^C signal does not
work on user level processes. But it works on applications like ping,
traceroute etc.

my user level application is:
#!/bin/sh

while true;
do
ps | grep traceMagnet
sleep 1
done


traceMagnet is a user level process. What can be the issue. I have
already enabled SIGINT.



Thanks a lot,
zix
 
Lew Pitcher...
Posted: Sat Oct 10, 2009 5:06 am
Guest
On Oct 10, 10:19 am, zix <zixe... at (no spam) gmail.com> wrote:
Quote:
Hi, I am working on a customised shell. I have been disabling/enabling
(SIGINT) signals on some conditions. I am finding ^C signal does not
work on user level processes. But it works on applications like ping,
traceroute etc.

There is nothing special about "user level processes" in general that
would cause them to ignore SIGINT. If SIGINT is delivered to a
runnable process, then the process either explicitly catches and
processes it, or the process will be terminated (default behaviour if
not explicitly caught).

If your "user level process" appears not to notice SIGINT, then you
either
a) have not sent SIGINT to the process (you sent it somewhere else),
or
b) the process is not runnable, or
c) the process explicitly catches and handles SIGINT (possibly by
ignoring SIGINT)

Quote:
my user level application is:
#!/bin/sh

while true;
do
   ps | grep traceMagnet
   sleep 1
done

traceMagnet is a user level process. What can be the issue. I have
already enabled SIGINT.


It is unclear to me which process you are attempting to SIGINT. Are
you trying to SIGINT your shell script? Or are you sending SIGINT to
"traceMagnet"? Or what.

Show us what you do, and what happens, and we'll be in a better
position to help you.


Quote:
Thanks a lot,
zix
 
zix...
Posted: Sat Oct 10, 2009 7:24 pm
Guest
Quote:
It is unclear to me which process you are attempting to SIGINT. Are
you trying to SIGINT your shell script? Or are you sending SIGINT to
"traceMagnet"? Or what.

Show us what you do, and what happens, and we'll be in a better
position to help you.

Thanks a lot,
zix

I am sending ^C to shell script, it does not stop. But when I sending
to ^C to ping/traceroute then it halts as expected(that means SIGINT
is enabled??). Any idea will be great.


thanx,
zix
 
André Gillibert...
Posted: Mon Oct 12, 2009 2:56 am
Guest
zix <zixenus at (no spam) gmail.com> wrote:
Quote:
Hi, I am working on a customised shell. I have been disabling/enabling
(SIGINT) signals on some conditions.

How?
Setting action to SIG_IGN with signal/sigaction?
Masking the signal?

In the first case, any program that would add its own SIGINT handler would automatically re-enable it. That may be what ping and traceroute do.
In the second case, some programs may change their signal mask, though, I would expect fewer to do so.

--
André Gillibert
 
Grant Edwards...
Posted: Mon Oct 12, 2009 7:39 am
Guest
On 2009-10-12, Joe Beanfish <joe at (no spam) nospam.duh> wrote:

Quote:
I've observed similar behavior quite often in shell loops. The ^C gets
to the program that's running at the moment (grep or sleep in your case)
that program quits and loop processing continues. But the shell running
the script largely ignores the ^C. Try setting a "trap" in the beginning
of the shell script.
trap "exit 1" 2 3 15

You can also do:

^Z
$ kill %1

<assuming 1 is the job number displayed when you hit Ctrl-Z>

--
Grant Edwards grante Yow! Am I in GRADUATE
at SCHOOL yet?
visi.com
 
Joe Beanfish...
Posted: Mon Oct 12, 2009 11:07 am
Guest
zix wrote:
Quote:
Hi, I am working on a customised shell. I have been disabling/enabling
(SIGINT) signals on some conditions. I am finding ^C signal does not
work on user level processes. But it works on applications like ping,
traceroute etc.

my user level application is:
#!/bin/sh

while true;
do
ps | grep traceMagnet
sleep 1
done


traceMagnet is a user level process. What can be the issue. I have
already enabled SIGINT.

I've observed similar behavior quite often in shell loops. The ^C gets
to the program that's running at the moment (grep or sleep in your case)
that program quits and loop processing continues. But the shell running
the script largely ignores the ^C. Try setting a "trap" in the beginning
of the shell script.
trap "exit 1" 2 3 15
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Mon Nov 30, 2009 6:47 pm