diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-01-31 13:43:18 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-01-31 13:43:18 +0200 |
commit | 6f9f2fd7a6952b544dccbf0bdc7f9c312f602afe (patch) | |
tree | 8bf0b45bb6578dee844dc92c1a90a93474f0fa7a /src/pies.h | |
parent | 7f20aa4f7e26d8f740b55bef98f0c3c78eca0e79 (diff) | |
download | pies-6f9f2fd7a6952b544dccbf0bdc7f9c312f602afe.tar.gz pies-6f9f2fd7a6952b544dccbf0bdc7f9c312f602afe.tar.bz2 |
Fix runlevel switching; handle powerfail commands.
* src/ctl.c (prog_serialize): List runlevels.
* src/pies.c (main): Set got_alarm after reloading configuration.
Handle ACTION_POWER.
* src/pies.h (ACTION_POWER): New constant.
(progman_running_p): Rename to progman_waiting_p. All uses changed.
(sysvinit_power): New proto.
(POWER_STAT_FILE): New define.
(POWER_STAT_FAIL,POWER_STAT_LOW,POWER_STAT_OK): New constants.
* src/prog.h (prog) <idx>: Remove.
(prog) <wait>: New member.
* src/progman.c (prog_lookup_by_idx): Remove.
(progman_waiting_p): Return 1 only if there is at least one
prog with v.p.wait set.
(prog_start): Initialize v.p.wait for sysvinit components.
(progman_start): Don't do anything if waiting for components from
the previous runlevel.
(progman_wake_sleeping): Likewise.
(progman_cleanup): Assume expect_term if waiting for components from
the previous runlevel.
Clear v.p.wait on exited progs.
* src/sysvinit.c (sysvinit_fifo_handler): Don't call progman_stop
when handling runlevel changes.
Handle INIT_CMD_POWERFAIL, INIT_CMD_POWERFAILNOW, and
INIT_CMD_POWEROK.
(sysvinit_sigtrans): Handle SIGPWR.
(is_comp_wait): Rewrite.
(power_stat_file): New variable.
(sysvinit_power): New function.
Diffstat (limited to 'src/pies.h')
-rw-r--r-- | src/pies.h | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -270,7 +270,8 @@ enum pies_action { ACTION_RESTART, ACTION_RELOAD, ACTION_CTRLALTDEL, - ACTION_KBREQUEST + ACTION_KBREQUEST, + ACTION_POWER }; extern char *instance; @@ -316,7 +317,7 @@ void pies_schedule_action (int act); void free_action (struct action *act); void register_prog (struct component *comp); -int progman_running_p (void); +int progman_waiting_p (void); size_t progman_running_count (void); void progman_start (void); void progman_wake_sleeping (int); @@ -513,6 +514,7 @@ int inittab_parse (const char *file); int sysvinit_sigtrans (int sig, int *pact); void sysvinit_runlevel_setup (int mask, int *wait); void sysvinit_sysdep_begin (void); +void sysvinit_power (void); extern char *sysvinit_environ_hint[]; extern char *init_fifo; @@ -521,6 +523,16 @@ extern char *init_fifo; # define INIT_FIFO "/dev/initctl" #endif +#ifndef POWER_STAT_FILE +# define POWER_STAT_FILE "/var/run/powerstatus" +#endif + +/* Power status values */ +#define POWER_STAT_FAIL 'F' +#define POWER_STAT_LOW 'L' +#define POWER_STAT_OK 'O' + +/* Request codes */ #define INIT_MAGIC 0x03091969 #define INIT_CMD_START 0 #define INIT_CMD_RUNLVL 1 |