| Author |
Unix Shutdown event
|
|
| varma.iitb@gmail.com 2006-02-20, 2:48 am |
| I am developing a service in UNIX. My service needs to get shutdown
event, when shutdown is issued. So that I can do something before
system is going for shutdown. My service should get shutdown event. How
can I do it. is there any system call for that.
varma
| |
| Gordon Burditt 2006-02-20, 2:48 am |
| >I am developing a service in UNIX. My service needs to get shutdown
>event, when shutdown is issued. So that I can do something before
>system is going for shutdown. My service should get shutdown event. How
>can I do it. is there any system call for that.
Processes are sent a signal by shutdown(8) before it actually
shuts down. On BSD systems this seems to be:
SIGINT shutdown -r (reboot)
SIGUSR1 shutdown -h (halt)
SIGUSR2 shutdown -p (power-down)
SIGTERM shutdown (to single-user)
Gordon L. Burditt
| |
| Maxim Yegorushkin 2006-02-20, 7:48 am |
|
Gordon Burditt wrote:
>
> Processes are sent a signal by shutdown(8) before it actually
> shuts down. On BSD systems this seems to be:
>
> SIGINT shutdown -r (reboot)
> SIGUSR1 shutdown -h (halt)
> SIGUSR2 shutdown -p (power-down)
> SIGTERM shutdown (to single-user)
I've been under impression that SIGUSR1/2 signals are free for use and
don't have any predefined semantics, so that their meaning depends only
on an application.
| |
| Gordon Burditt 2006-02-20, 5:54 pm |
| >> >I am developing a service in UNIX. My service needs to get shutdown
>
>I've been under impression that SIGUSR1/2 signals are free for use and
>don't have any predefined semantics, so that their meaning depends only
>on an application.
I got that info from the source code of shutdown(8) on FreeBSD.
Gordon L. Burditt
| |
| Fletcher Glenn 2006-02-20, 5:54 pm |
|
<varma.iitb@gmail.com> wrote in message
news:1140413082.700044.197860@z14g2000cwz.googlegroups.com...
>I am developing a service in UNIX. My service needs to get shutdown
> event, when shutdown is issued. So that I can do something before
> system is going for shutdown. My service should get shutdown event. How
> can I do it. is there any system call for that.
>
> varma
>
If your service needs to be shut down in a particular sequence relative to
other processes, then you may need to a script into /etc/rc?.d where ? is
the run level.
--
Fletcher Glenn
| |
| varma.iitb@gmail.com 2006-02-21, 2:49 am |
|
Fletcher Glenn wrote:
> <varma.iitb@gmail.com> wrote in message
> news:1140413082.700044.197860@z14g2000cwz.googlegroups.com...
>
> If your service needs to be shut down in a particular sequence relative to
> other processes, then you may need to a script into /etc/rc?.d where ? is
> the run level.
thanks for your replies.
My service is not related to other processes. When my service recieves
shutdown event, it will do some steps ans exit.
I am planning to use SIGTERM and function handler
>
> --
>
> Fletcher Glenn
| |
| SM Ryan 2006-02-21, 2:49 am |
| # <varma.iitb@gmail.com> wrote in message
# news:1140413082.700044.197860@z14g2000cwz.googlegroups.com...
# >I am developing a service in UNIX. My service needs to get shutdown
# > event, when shutdown is issued. So that I can do something before
# > system is going for shutdown. My service should get shutdown event. How
# > can I do it. is there any system call for that.
# >
# > varma
# >
#
# If your service needs to be shut down in a particular sequence relative to
# other processes, then you may need to a script into /etc/rc?.d where ? is
# the run level.
Your mileage may vary. Latest MacOSX is going a different route
of init and all of its protocols. You might need to adapt to a
number of different schemes.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
There are subtler ways of badgering a witness.
| |
| varma.iitb@gmail.com 2006-02-21, 7:49 am |
|
SM Ryan wrote:
> # <varma.iitb@gmail.com> wrote in message
> # news:1140413082.700044.197860@z14g2000cwz.googlegroups.com...
> # >I am developing a service in UNIX. My service needs to get shutdown
> # > event, when shutdown is issued. So that I can do something before
> # > system is going for shutdown. My service should get shutdown event. How
> # > can I do it. is there any system call for that.
> # >
> # > varma
> # >
> #
> # If your service needs to be shut down in a particular sequence relative to
> # other processes, then you may need to a script into /etc/rc?.d where ? is
> # the run level.
>
> Your mileage may vary. Latest MacOSX is going a different route
> of init and all of its protocols. You might need to adapt to a
> number of different schemes.
I am using Redhat Linux. I have written a C program(with signal handler
for SIGTERM) and running the program. If I give kill -TERM <pid>, then
my programme is responding for the signal.
But when I shutdown the system it is not responding (I am logging the
message). seems my program is not recieving SIGTERM signal. But when I
say shutdown, it will send SIGTERM signal to all running process,
right? and my process is running.
How can I do that one?
>
> --
> SM Ryan http://www.rawbw.com/~wyrmwif/
> There are subtler ways of badgering a witness.
| |
| Christian Gollwitzer 2006-02-21, 7:49 am |
| varma.iitb@gmail.com wrote:
> I am using Redhat Linux. I have written a C program(with signal handler
> for SIGTERM) and running the program. If I give kill -TERM <pid>, then
> my programme is responding for the signal.
> But when I shutdown the system it is not responding (I am logging the
> message). seems my program is not recieving SIGTERM signal. But when I
> say shutdown, it will send SIGTERM signal to all running process,
> right? and my process is running.
> How can I do that one?
Perhaps the parent process of your service might be a shell or so that
got shut down before init sends the SIGTERM, e.g. if you ran your
service from a terminal window in X. In that case the program recieves a
SIGHUP. You should catch that signal, too. Perhaps you catch and log all
signals to see what happens?
Christian
| |
| varma.iitb@gmail.com 2006-02-21, 5:54 pm |
| Thanks. It was working. before parent process of my service is shell...
so it created problem
| |
| Logan Shaw 2006-02-23, 2:54 am |
| Gordon Burditt wrote:
[vbcol=seagreen]
>
> I got that info from the source code of shutdown(8) on FreeBSD.
I think that's talking about the signals which are used to communicate
between shutdown(8) and init(8), NOT what signals daemons and other programs
get when a shutdown is happening.
| |
| Maxim Yegorushkin 2006-02-26, 10:15 am |
|
Logan Shaw wrote:
> Gordon Burditt wrote:
>
>
> I think that's talking about the signals which are used to communicate
> between shutdown(8) and init(8), NOT what signals daemons and other programs
> get when a shutdown is happening.
This statement makes a lot of sense.
|
|
|
|