[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
|
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
9945.0. "What is kill(0,SIGUSR1) means in Digital UNIX ?" by HGOV08::SOCHUNWAH () Mon May 26 1997 23:56
Hello,
This questions is raised on behalf of a remote-site enduser in China,
they are performing some C language coding and encountered problem when using
the kill(0,SIGUSR1) function.
According to the 'kill' man information and customer's understanding,
kill 0 will terminate all it's owned background processes, but kill(0,SIGUSR1)
should only send a signal to SIGUSR1 of the relevant process accrodingly.
The enduser made use of the following example to illustrate his
explaination about the kill(0,SIGUSR1) -- if they use kill(314,SIGUSR1),
i.e. pid other than 0, there will be no problem :
> #include <signal.h>
> #include <ctype.h>
>
> main()
> {
> printf("this is first clouse for test:);
> kill(0,SIGUSR1);
> printf("this is end of test");
> }
Whenever the program run, it didn't give any printf line, and it'll
return to # prompt right away. If we use kill(123,SIGUSR1), I can have the
printf line display on screen.
> # ./a.out
> User defined signal 1
> #
The customer tried to setup some "menu setting" for their endusers, but
whenever they use the kill function as described above, the enduser's process
and it's background proceesses will be all terminated and fall back to login
prompt again.
Can anybody give an exlpaination about the phenonmean of the
kill(0,XXX) function ? I beleive it's normal becasue I tried it myself
on a ULTRIX system and have the same result (customer's system is running
OSF/1 V3.2B). Customer said the same command works just fine under SCO UNIX,
but I think kill 0 may means differnt thing in SCO UNIX.
Thanks in Advance !
SO
T.R | Title | User | Personal Name | Date | Lines |
---|
9945.1 | Use SIGTERM and signal handling | ALFAM7::STREPPEL | | Tue May 27 1997 06:43 | 16 |
| kill(0, SIGUSR1) does send the SIGUSR1 signal to all processes whose
process group ID is equal to the process group ID of the sender. I.e.
it is also sent to the sending process. As this does not do any signal
handling it is killed. As printf is line buffered but the first printf
in the program has no trailing \n the line is not yet printed when the
signal arrives and gets lost.
SIGUSR1 is only useful for process that know what SIGUSR1 is meant for.
By itself SIGUSR1 just has no meaning except that it's a signal. Sender
and addressee must agree on a common understanding.
What you probably would like to use is SIGTERM which is handled by most
background - at least the well coded - processes. But be careful that
the sending process knows how to deal with it too.
Hartmut
|