# Revision history [back]

Just to add to the answer by @FooBar (ROS nodes are really just regular Linux programs that have chosen to communicate with each other via the ROS middleware): shutting down a Linux system with a desktop environment is often possible without using something like shutdown (which requires special privileges). See "Linux: Programatically shutdown or reboot computer from a user-level process" on stackoverflow for an example where they use ConsoleKit / DBus:

dbus-send \
--system \
---dest=org.freedesktop.ConsoleKit \
--type=method_call \
/org/freedesktop/ConsoleKit/Manager \
org.freedesktop.ConsoleKit.Manager.Stop


You could invoke dbus-send using the system(..) function call in C/C++, or execute it from a Python node.

For Python there are better (more integrated) ways to interface with ConsoleKit / DBus (copied from "shutting down computer (linux) using python" on stackoverflow):

import dbus
sys_bus = dbus.SystemBus()
ck_srv = sys_bus.get_object('org.freedesktop.ConsoleKit',
'/org/freedesktop/ConsoleKit/Manager')
ck_iface = dbus.Interface(ck_srv, 'org.freedesktop.ConsoleKit.Manager')
stop_method = ck_iface.get_dbus_method("Stop")
stop_method()


You could fi wrap the call to stop_method() (which is just an example) in a ROS service call (I wouldn't use parameters for this, it is clearly a synchronous action).