Shut down the system


#include <sys/shutdown.h>

void shutdown_system( int type,
                      int flags );


The type of shutdown; one of the following:
  • SHUTDOWN_REBOOT—reboot the system.
  • SHUTDOWN_SYSTEM—shut down the system.
Zero or more of the following bits:
  • FLAG_FAST—do a "fast" shutdown.
  • FLAG_DEBUG—debug mode; don't actually shut down.
  • FLAG_VERBOSE—be verbose.
  • FLAG_VERY_VERBOSE—be very verbose.
  • FLAG_NONROOT—ignore root privileges (not used in the default library).
  • FLAG_UNATTENDED—don't ask for options (not used in the default library).
  • FLAG_NO_DAEMON—don't daemonize the process.



Use the -l shutdown option to qcc to link against this library.


The shutdown_system() function reboots or shuts down the system, depending on the type argument. It tries first to shut down any processes.

You can customize this function by providing your own callouts to override those in the library:

This library is used by shutdown, with callouts provided by the utility.

shutdown_classify() callout

ProcessClass_t shutdown_classify( ProcessInfo_t const *pip );

This callout determines whether an application is console-based, based on the information provided in the structure that pip points to. The ProcessInfo_t structure is defined as follows:

typedef struct
    uint64_t start_time;
    pid_t pid;
    int8_t class;
    uint8_t padding[3];
    char *name;
} ProcessInfo_t;

The shutdown_system() function recognizes some applications by their name or other information, and calls shutdown_classify() to determine the type of applications that it doesn't recognize.

The shutdown_classify() callout should return one of the defined class types:

The default stub unconditionally returns CLASS_UNKNOWN.

shutdown_display() callout

void shutdown_display( int type,
                       DisplayData_t const *display);

This callout can display the name of a process or class of processes being shut down, depending on the type argument:

The default stub does nothing.

The DisplayData_t structure provides information about what's currently being shut down. It's defined as follows:

typedef union
    int proc_class;         /* use for DISPLAY_CLASS */
    char const *proc_name;  /* use for DISPLAY_PROC */
} DisplayData_t;

The proc_class member is one of the class types that shutdown_classify() returns.

shutdown_done() callout

void shutdown_done( int type );

This callout is called before shutting down the display processes, but after shutting down the rest. The type argument is the typed passed to shutdown_system().

The default stub does nothing.

shutdown_error() callout

void shutdown_error( char const *msg );

The library invokes this callout if an error has occurred; the library exits, indicating a failure, after issuing this callout. The default stub does nothing.

shutdown_process() callout

void shutdown_process(void);

This callout is called to process intermediate events during the shutdown. The default stub does nothing.

shutdown_progress() callout

void shutdown_progress( int done,
                        int total );

This callout is called to display the progress being made at shutting down. The done argument indicates the number of processes already shut down, out of the given total.

The default stub does nothing.

shutdown_prompt() callout

int shutdown_prompt(char const *name,pid_t pid);

This callout is called to deal with a process that isn't responding. It should return one of the following to indicate to the library how to deal with the errant process:

The default stub returns PROMPT_SKIP.


QNX Neutrino

Cancellation point No
Interrupt handler No
Signal handler No
Thread No