|
Home > Archive > Unix Programming > September 2005 > signals
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| rahul8143@gmail.com 2005-09-18, 5:55 pm |
| hello,
what is difference between SIGTERM and SIGINT? What happens when
process receives either signal in detail?
regards,
rahul
| |
| Maxim Yegorushkin 2005-09-18, 5:55 pm |
|
rahul8143@gmail.com wrote:
> hello,
> what is difference between SIGTERM and SIGINT? What happens when
> process receives either signal in detail?
> regards,
Check out the first table at
http://www.opengroup.org/onlinepubs...s/signal.h.html
| |
| Rich Gibbs 2005-09-18, 5:55 pm |
| rahul8143@gmail.com said the following, on 09/18/05 11:15:
> hello,
> what is difference between SIGTERM and SIGINT? What happens when
> process receives either signal in detail?
> regards,
> rahul
>
It would be much more efficient if you would also post your teacher's
E-mail address; then we could submit the answers directly.
How do you expect to learn anything without doing your own homework?
--
Rich Gibbs
richg74@gmail.com
"You can observe a lot by watching." -- Yogi Berra
| |
| Roger Leigh 2005-09-18, 5:55 pm |
| rahul8143@gmail.com writes:
> what is difference between SIGTERM and SIGINT?
man 7 signal
> What happens when process receives either signal in detail?
man 2 kill
man 2 signal
man 2 sigaction
man 2 wait
--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
| |
| rahul8143@gmail.com 2005-09-20, 2:49 am |
|
Rich Gibbs wrote:
> rahul8143@gmail.com said the following, on 09/18/05 11:15:
>
> It would be much more efficient if you would also post your teacher's
> E-mail address; then we could submit the answers directly.
>
> How do you expect to learn anything without doing your own homework?
>
Its not a homework question. i am learning on my own. and what i
learnt is that SIGINT is used to send ctrl+c interrupt signal to
currently running program. and SIGTERM is used for termination of the
process then whats is difference between them?
And when proess receive signal i know that its control
transferred from currently running process to signal handler thats it
but then what? what about that process's memory data,registers are they
saved or not? does context switch occurs or not? signal handler
executes in user space isn't it?
> --
> Rich Gibbs
> richg74@gmail.com
> "You can observe a lot by watching." -- Yogi Berra
| |
| Pascal Bourguignon 2005-09-20, 7:49 am |
| rahul8143@gmail.com writes:
> Rich Gibbs wrote:
> Its not a homework question. i am learning on my own. and what i
> learnt is that SIGINT is used to send ctrl+c interrupt signal to
> currently running program. and SIGTERM is used for termination of the
> process then whats is difference between them?
It works this way:
The terminal is configured with stty.
(type: man 1 stty
stty -a
for example, the following characters are configured here:
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O;)
When you type the character that is configured for intr, the terminal
driver sends the SIGINT signal to the process attached to the terminal.
If you type the character configued for quit, it sends the SIGQUIT
signal.
And for the character configured for susp, it sends the SIGSTOP signal
(which suspends the process, to be resumed when it receives SIGCONT).
Then you need to read signal(7) to know what happens when a process
receives a signal. Type: man 7 signal
This manual page indicates for each signal the default action.
The default action for Both SIGINT and SIGTERM is to terminate the process.
But as you've seen when you've read man 1 stty, the terminal can only
send a SIGINT, not a SIGTERM signal.
Note that all signals but SIGKILL can be ignored or handled. Some
programs are designed not to terminate when they receive the SIGINT
signal, but merely to terminate the current action and revert to the
main menu for example.
The SIGKILL signal cannot be ignored and provoke the immediate
termination of the process by the OS. The process can still linger if
it's waiting in the kernel for I/O to complete, but it is killed
immediately.
So you've got these three level of interruption:
SIGINT: stop the current activity and wait for new user input.
SIGTERM: terminate the program, closing cleanly the files, network
connections, databases, etc.
SIGKILL: forcibly kill a process without leaving it a chance to clean up.
The exact difference between two signals (apart from SIGKILL and
SIGSTOP/SIGCONT), depends actually on the signal handler installed by
the program, or the default. A lot of program install the same signal
handler on both, so there's no difference for these programs.
> And when proess receive signal i know that its control
> transferred from currently running process to signal handler thats it
> but then what? what about that process's memory data,registers are they
> saved or not? does context switch occurs or not? signal handler
> executes in user space isn't it?
The signal handler is but a function in the process. There is no
context switch. The signal handler works in the same virtual memory
space as the process: it's a simple function inside the process.
As with any other function call the signal handling code stacks the
registers, and restore them on return.
The only difference between the invocation of a signal handler
function and that of the other functions of the program, is that in
the case of the signal handler, there's no call in the program: the
signal handler function can be "called" virtually from any point in
the program.
If you want to know all the details, the best is to read the sources
of some unix (eg. linux or freebsd); start with the kill(2) syscall.
--
__Pascal Bourguignon__ http://www.informatimago.com/
Nobody can fix the economy. Nobody can be trusted with their finger
on the button. Nobody's perfect. VOTE FOR NOBODY.
| |
| Barry Margolin 2005-09-21, 2:50 am |
| In article <1127200661.092229.61230@g43g2000cwa.googlegroups.com>,
rahul8143@gmail.com wrote:
> Its not a homework question. i am learning on my own. and what i
> learnt is that SIGINT is used to send ctrl+c interrupt signal to
> currently running program. and SIGTERM is used for termination of the
> process then whats is difference between them?
Some programs treat user-initiated signals differently from programmatic
signals. For instance, many programs that have their own internal CLI
(e.g. the ftp command) use Control-C as a way to get back to the command
prompt. But they should still exit completely if SIGTERM is sent to
them.
> And when proess receive signal i know that its control
> transferred from currently running process to signal handler thats it
> but then what? what about that process's memory data,registers are they
> saved or not? does context switch occurs or not? signal handler
> executes in user space isn't it?
It's as if the program had executed a function call to the handler
function at the time of the signal.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
|
|
|
|
|