Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How reboot and shutdown actions performed in gentoo?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
yagamiram
n00b
n00b


Joined: 17 Feb 2015
Posts: 13

PostPosted: Tue Mar 03, 2015 11:08 pm    Post subject: How reboot and shutdown actions performed in gentoo? Reply with quote

Hi to all,

The command to reboot in a gentoo machine is /sbin/shutdown -r now

and similarly the command to shutdown a gentoo machine is /sbin/shutdown -h now.

Now when the command is executed what operations does retboot and shutdown do ?

When I looked into the file shutdown in /sbin folder it is of binary mode. I'm curious to know how it reboots? what it does ? In which sequence it stops the process that are currently running in the gentoo machine ?

If I started a service that I have written, will it be automatically stopped when the reboot call is made ? Does it stop the process or kills the process ?

If the user-defined service is written how it should be updated to the shutdown process to stop automatically when the shutdown command is passed ?

If I want to edit the shutdown operation how to perform it ?

Note: I'm not looking for boot sequence and I'm only cared about the shutdown/reboot process.

Since I'm a newbie to Linux/Gentoo , I request you all to give an explanation in detail to understand this operation perfectly.
Back to top
View user's profile Send private message
binbash
n00b
n00b


Joined: 04 Jul 2002
Posts: 16

PostPosted: Tue Mar 03, 2015 11:42 pm    Post subject: Reply with quote

ok. At a shell prompt type: man shutdown

and you can read all about it. no need to rewrite it here :)

You can use the "man" command to read the (man)ual on any program on your system.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Tue Mar 03, 2015 11:54 pm    Post subject: Reply with quote

yagamiram ...

shutdown is part of sysvinit, when run it looks to /etc/inittab to see what it should do in the case of that signal being called. With openrc it will call '/sbin/rc shutdown' or '/sbin/rc reboot', this in turn runs whatever is in that runlevel, so for example:

Code:
# rc-status shutdown | awk 'gsub(/[ |\t]+/," ")1'
Runlevel: shutdown
 savecache [ stopped ]
 killprocs [ stopped ]
 mount-ro [ stopped ]

In the case of your 'service' this will be killed by /etc/init.d/killprocs ... first with signal 15 (-TERM ... which is a terminate/exit, and cleanly) and then signal -9 (-KILL ... which is a signal to exit regardless of how cleanly the process terminates).

HTH & best ... khay
Back to top
View user's profile Send private message
yagamiram
n00b
n00b


Joined: 17 Feb 2015
Posts: 13

PostPosted: Wed Mar 04, 2015 12:24 am    Post subject: Reply with quote

Thanks for the information @binbash and @khayyam ... I willl look into it and If any doubts I get I will post here...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum