From: neilsolent on
Hi

The C program below certainly reboots my Solaris 10 system, but it
does not seem to do it cleanly (doesn't send SIGTERM to the running
processes). If I run the Solaris reboot command though, that does seem
to cleanly reboot.
How come?


[code]

#include <sys/reboot.h>

int main(int argc, char* argv[])
{
reboot(RB_AUTOBOOT, NULL);
return 0;
}

[/code]
From: John Gordon on
In <b7e4da0b-bd35-4233-98da-ee6ba2ea1d77(a)j19g2000yqk.googlegroups.com> neilsolent <n(a)solenttechnology.co.uk> writes:

> The C program below certainly reboots my Solaris 10 system, but it
> does not seem to do it cleanly (doesn't send SIGTERM to the running
> processes). If I run the Solaris reboot command though, that does seem
> to cleanly reboot.
> How come?

At a guess, because the reboot command does more than just call reboot().

--
John Gordon A is for Amy, who fell down the stairs
gordon(a)panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

From: Scott Lurndal on
neilsolent <n(a)solenttechnology.co.uk> writes:
>Hi
>
>The C program below certainly reboots my Solaris 10 system, but it
>does not seem to do it cleanly (doesn't send SIGTERM to the running
>processes). If I run the Solaris reboot command though, that does seem
>to cleanly reboot.
>How come?
>
>
>[code]
>
>#include <sys/reboot.h>
>
>int main(int argc, char* argv[])
>{
> reboot(RB_AUTOBOOT, NULL);
> return 0;
>}
>
>[/code]

because the reboot(2) system call is not intended to be used by user
applications.

If you want to initiate a reboot from a (suitably privileged) user
application call the 'shutdown' utility using the system(3) library
function (which will, after running all the appropriate shutdown scripts
in /etc/init.d, execute the reboot(2) system call itself).
From: David Schwartz on
On Jan 12, 2:20 pm, neilsolent <n...(a)solenttechnology.co.uk> wrote:

> The C program below certainly reboots my Solaris 10 system, but it
> does not seem to do it cleanly (doesn't send SIGTERM to the running
> processes). If I run the Solaris reboot command though, that does seem
> to cleanly reboot.
> How come?

The reboot command sends a SIGTERM to the running process before
rebooting and your code doesn't. Your question is self-answering. Your
code doesn't send a SIGTERM to the running processes because it
contains no code that would do that anywhere in it. It simply commands
the system to reboot, so that's what happens.

DS
From: Barry Margolin on
In article
<9711e184-7cb6-46e4-9c55-d4b7bd03aea4(a)j19g2000yqk.googlegroups.com>,
David Schwartz <davids(a)webmaster.com> wrote:

> On Jan 12, 2:20�pm, neilsolent <n...(a)solenttechnology.co.uk> wrote:
>
> > The C program below certainly reboots my Solaris 10 system, but it
> > does not seem to do it cleanly (doesn't send SIGTERM to the running
> > processes). If I run the Solaris reboot command though, that does seem
> > to cleanly reboot.
> > How come?
>
> The reboot command sends a SIGTERM to the running process before
> rebooting and your code doesn't. Your question is self-answering. Your
> code doesn't send a SIGTERM to the running processes because it
> contains no code that would do that anywhere in it. It simply commands
> the system to reboot, so that's what happens.
>
> DS

More to the point, the reboot() system call is what the reboot command
calls AFTER it has broadcast a shutdown notice on all the terminals,
sent all the SIGTERMs, etc. Eventually it has to tell the OS to reboot,
and it does it using this system call.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***