aboutsummaryrefslogtreecommitdiff
path: root/src/sysvinit.c
AgeCommit message (Collapse)AuthorFiles
2019-05-23Update copyright yearsSergey Poznyakoff1
2019-05-20Upgrade grecsSergey Poznyakoff1
2017-01-02Happy GNU YearSergey Poznyakoff1
2016-03-19Fix some compilation issues on SolarisSergey Poznyakoff1
* configure.ac: Check for libnsl * src/pies.c (string_to_syslog_facility): LOG_AUTHPRIV and LOG_FTP may be undefined. * src/piesctl.c (EX_NOTFOUND): Rename to EX_PIES_NOTFOUND. (com_list): Use default_cond. * src/sysvinit.c (console_stty): Make sure CBAUDEX is defined. * src/utmp.c (fill_utmp): Declare locals right before using them.
2016-03-06Reimplement the telinit legacy interface.Sergey Poznyakoff1
pies -T is now fully compatible with the legacy telinit command * src/telinit.opt: New file. * src/Makefile.am: Add telinit.opt * src/cmdline.opt (-T): Remove explicit variable. Rest of command line is processed specially. * src/pies.h (telinit): Change prototype. * src/sysvinit.c (telinit): Rewrite. * src/.gitignore: Update. * doc/pies.texi: Document telinit.
2016-03-02Configurable pathname of the emergency shellSergey Poznyakoff1
* configure.ac (EMERGENCY_SHELL): New arg_var. * src/Makefile.am (AM_CPPFLAGS): Define EMERGENCY_SHELL. * src/sysvinit.c (emergency_shell): Initialize with the value of EMERGENCY_SHELL.
2016-03-01BugfixSergey Poznyakoff1
* src/sysvinit.c (sysvinit_environ_hint): Fix dimensions.
2016-02-28Synchronize changes in runlevel with configuration reloadsSergey Poznyakoff1
State transition algorithm used this far could cause spurious component wakeups in some cases. Consider the following scenario: being in runlevel N, the configuration is changed so that a component X is added at runlevel N. Then a change to runlevel N+1 is initiated. What happens then is that X is woken up (still being in runlevel N) and terminated shortly afterwards, upon entering runlevel N+1. To avoid this, configuration must be reloaded after runlevel changes. * src/ctl.c (res_runlevel): Don't initiate ACTION_RELOAD after setting the runlevel. * src/pies.c (main): Begin main event loop with call to pies_pause. * src/pies.h (pies_set_hook): New proto. (inittrans): Remove proto. * src/socket.c (pies_set_hook): New function. (pies_pause): Call pies_pause_hook if defined. * src/sysvinit.c (inittrans): Change to static. If transition was initiated by user (e.g. by invoking telinit), schedule ACTION_RELOAD. (sysvinit_begin): Set inittrans as pies_hook
2016-02-28Minor changeSergey Poznyakoff1
2016-02-25Implement "telinit environ" ctl commandSergey Poznyakoff1
* src/ctl.c: New endpoint "environ" * src/pies.h (sysvinit_envlocate) (sysvinit_envdelete) (sysvinit_envupdate): New protos. * src/piesctl.c: New subcommand "telinit environ". * src/sysvinit.c (sysvinit_envlocate) (sysvinit_envdelete) (sysvinit_envupdate): New functions. (sysvinit_begin): Create allocated copies of instance and pies_master_argv to avoid them being rewritten by calls to mf_proctitle_format
2016-02-24Changes in prog structureSergey Poznyakoff1
* src/prog.h (prog): Remove .facility. Use facility from the component. (active,wait,stop): Move from union into the main struct. All uses changed.
2016-02-24Minor stylistic changeSergey Poznyakoff1
2016-02-23Improve loggingSergey Poznyakoff1
* po/POTFILES.in: Add missing source files. * grecs: Upgrade. * src/diag.c (pies_diag_printer): New function. (logfuncall): New function. * src/pies.h: Add new prototypes. * src/pies.c (main): Initialize grecs_print_diag_fun * src/acl.c: Uniformly use double-quotes in messages. Use logfuncall where applicable. * src/comp.c: Likewise. * src/ctl.c: Likewise. * src/inetd-bi.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/piesctl.c: Likewise. * src/progman.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise.
2016-02-22Provide a default single-user entry in init modeSergey Poznyakoff1
This complements 6aac230c. The entry is created unless a component for runlevel S already exists. * src/comp.c (component_foreach): New function. * src/pies.h: Likewise. * src/sysvinit.c (inittab_parse): Provide default S entry unless one is already defined.
2016-02-21Provide fall-back entry in init modeSergey Poznyakoff1
* src/sysvinit.c (inittab_parse): Provide default entry if inittab cannot be read or if it defined no components. * src/comp.c (component_list_is_empty): New function. * src/pies.c (pies_read_config): Always return 0 in init mode. (main): Use LOG_DAEMON in init mode. * src/pies.h (component_list_is_empty): New proto.
2016-02-19Revamp program termination after reconfiguring.Sergey Poznyakoff1
* src/pies.h (PIES_CHLD_GC): New op. (progman_stop_tag): Remove proto. * src/pies.c (main): Handle PIES_CHLD_GC: stop all programs marked for termination. * src/comp.c (component_config_commit): Mark leftover components for termination, instead of waiting for them to terminate. * src/sysvinit.c (runlevel_setup_prog): Skip prog if its active status didn't change. Mark inactivated progs for termination. (sysvinit_runlevel_setup): Schedule PIES_CHLD_GC. (inittrans): Don't wait for programs to terminate. That will be done in the main loop. * src/prog.h (prog)<stop>: New boolean member. * src/progman.c (progman_cleanup) (progman_stop_component): Clear the stop flag. (progman_gc): New function. (progman_stop_tag): Remove.
2016-02-18Fix activation/deactivation of network listeners.Sergey Poznyakoff1
* src/ctl.c (prog_active): New function. (prog_serialize): Use prog_active to report prog's activity state. For listener components, return also their service and tcpmux master names, if applicable. (fun_stop): Stop listeners as well. (fun_start): Start listeners. (ctlio_end): Don't close fd: this is done by deregister_socket * src/inetd-bi.c (tcpmux_help): Don't list inactive components. * src/prog.h (prog_activate_listener) (prog_deactivate_listener): New protos. * src/progman.c (prog_lookup_by_tag) (prog_lookup_by_service): Remove. (progman_cleanup): Fix coredump (premature free). (progman_stop_component): If component is a listener, deactivate it. (prog_activate_listener) (prog_deactivate_listener): New functions. * src/socket.c (delete_sockinst): Close the socket descriptor. * src/sysvinit.c (sysvinit_fifo_handler, create_fifo): Don't close fd, leave that to deregister_socket.
2016-02-18Improve loggingSergey Poznyakoff1
* src/diag.c: Rewrite. (vdiagmsg,diagmsg): New functions. * src/pies.c (main): Set DIAG_REOPEN_LOG for init process. * src/pies.h (DIAG_REOPEN_LOG): New flag (DIAG_TO_MASK,DIAG_ALL): New constants. (diagmsg): New proto. * src/sysvinit.c: Add log messages in important transition points (inittrans): Reinitialize logging to syslog upon transition to normal mode.
2016-02-17Fix state transitionsSergey Poznyakoff1
* src/pies.c (main): Move call to pies_schedule_children to inittrans. * src/progman.c (progman_cleanup): Minor change. * src/sysvinit.c (enablecomp): Change prog status to stopped when leaving its runlevel. (sysvinit_set_runlevel): Raise SIGALRM instead of calling inittrans directly. (inittrans): Fix wait logic.
2016-02-16Associate program's activity flag with prog, instead of with component.Sergey Poznyakoff1
The CF_DISABLED flag is still retained to indicate that the component is disabled administratively. * src/prog.h (prog.v.p) <active>: New member. (IS_ACTIVE_COMPONENT): Use active flag. * src/comp.c (component_finish): Don't modify component flags. * src/ctl.c (prog_serialize): Replace attribute "disabled" with "active". (fun_stop): Set prog->v.p.active * src/pies.c (main): Use pies_master_argv to check whether program name is absolute. * src/piesctl.c (print_comp): Check "active" attribute. * src/progman.c (register_prog0): Set prog->v.p.active. (progman_create_sockets): Remove components if their socket cannot be opened. (progman_lookup_tcpmux, prog_open_socket) (prog_start, progman_start) (prog_start_prerequisites, react): Operate on prog->v.p.active to test/change prog's activity state. * src/sysvinit.c (enablecomp, runlevel_setup_prog): Operate on prog->v.p.active to test/change prog's activity state. (demand_prog, IS_RUNNING_DISABLED_PROG): Likewise.
2016-02-15Implement emergency shell.Sergey Poznyakoff1
* src/pies.c (main): Move init-specific command line handling to sysvinit_parse_argv. * src/pies.h (dfl_level): Remove extern. (sysvinit_parse_argv): New proto. * src/sysvinit.c (sysvinit_parse_argv): New function. (sysvinit_begin): Start emergency shell, if requested.
2016-02-14Fix handling of wait componentsSergey Poznyakoff1
* src/pies.h (PIES_COMP_WAIT): Remove. (PIES_COMP_MASK): Save one bit. (PIES_CHLD_NONE, PIES_CHLD_CLEANUP) (PIES_CHLD_WAKEUP): New constants. (pies_schedule_children): New proto. (sysvinit_runlevel_setup): Change signature. * src/pies.c (children_cleanup, got_alarm): Merge into single static variable children_op. All uses updated. (pies_schedule_children): New function. (sig_handler): Update (main): Don't call ctl_open for init process. It is done by inittrans after transition from boot to normal state. Update to use pies_schedule_children. * src/prog.h (IS_ACTIVE_COMPONENT): New macro. * src/progman.c (prog_start): Don't modify prog->v.p.wait. (progman_wake_sleeping): Start usual components only after all "wait" components have terminated. (progman_cleanup): If a "wait" component has terminated, request PIES_CHLD_WAKEUP. * src/sysvinit.c (enstate) <wait>: Remove. (enablecomp): Update. (runlevel_setup_prog): Set prog->v.p.wait. (sysvinit_runlevel_setup): Take only one parameter. (inittrans): Remove "wait" and the related mess. Call ctl_open after transition boot -> normal.
2016-02-13Stop disabled components when switching runlevels.Sergey Poznyakoff1
* src/prog.h (status_enabled, status_disabled): Remove. (status_stopped, status_running): New modes. All uses updated. * src/comp.c (component_finish): Disable ondemand component by default. * src/ctl.c (json_object_set_bool): New function. (pies_status_str): Update. (prog_serialize): Set "disabled" attribute. (fun_stop, fun_start): Use CF_DISABLED flag. (res_runlevel): Schedule ACTION_RELOAD. * src/pies.h (json_object_set_bool): New proto. * src/piesctl.c (status_trans): Reflect changes in modes. (print_comp): Check the "disabled" attribute. * src/progman.c (register_prog0) (prog_open_socket,prog_start,prog_stop) (progman_wake_sleeping) (prog_start_prerequisites) (react, progman_cleanup) (progman_stop_component): Update. (no_children_left): Fix. * src/sysvinit.c (enablecomp): Make CF_DISABLED flag persist for ondemand components. (runlevel_setup_prog): Use CF_DISABLED flag. (inittrans): Stop inactivated processes. * doc/pies.texi: Update.
2016-02-13Implement on-demaind components; implement control socket telinit interface.Sergey Poznyakoff1
* src/pies.h: Include json.h (sysvinit_report, sysvinit_set_runlevel) (json_object_set_string, json_object_set_number): New protos. * src/ctl.c (ctlio_resource)<predicate>: New member. (restab): New endpoint: runlevel. Available only if run as pid 1. (find_resource): If predicate is not NULL, call it to confirm that the endpoint is available. * src/piesctl.c: New subcommand "telinit". * src/sysvinit.c (sysvinit_set_runlevel): New function. (sysvinit_fifo_handler): Implement on-demaind components.
2016-01-31Support sysvinit ondemand components.Sergey Poznyakoff1
* src/ctl.c (fun_start): Handle status_finished same as status_sleeping (for restarting ondemand components). * src/progman.c: Respawn ondemand components. * src/sysvinit.c (enablecomp): Handle pies_comp_ondemand. (sysvinit_demand): New function. (sysvinit_fifo_handler): Handle ondemand runlevels. (inittab_parse): Support "off" fields. Convert runlevels to upper case.
2016-01-31Fix runlevel switching; handle powerfail commands.Sergey Poznyakoff1
* 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.
2016-01-30Fix configuration reload and telinit qSergey Poznyakoff1
* src/comp.c (component_link): Always link after the REF. component. If REF is NULL, link at list head. (component_append): New function. (component_create): Use component_append. (component_free): Fix double-free. * src/pies.c (pies_reload): Call sysvinit_runlevel_setup. * src/progman.c (progman_stop_component): Remove inactive components. * src/sysvinit.c (sysvinit_fifo_handler): Schedule ACTION_RELOAD. on receiving INIT_CMD_RUNLVL. (sysvinit_sigtrans): Don't handle SIGHUP.
2016-01-21Cleanup: redo configuration file handling and dependency tracking.Sergey Poznyakoff1
Implement clean configuration reload on SIGHUP. Use SIGUSR1 to restart the program (previously initiated by SIGHUP). * src/Makefile.am (pies_SOURCES): Add comp.c * src/comp.c: New file. * src/acl.c (pies_acl_free): Don't coredump on NULL arg. (_parse_from): Set cmp function for the sockaddr list. (_acl_common_section_parser): Set cmp function for the ACL (pies_acl_cmp): New function. * src/acl.h (pies_acl_cmp): New proto. * src/cmdline.opt: Remove option --dump-prereq. Add options --trace-prereq and --trace-depend. * src/ctl.c: Use prog_tag to access tag of struct prog. * src/depmap.c (depmap_clear) (depmap_clear_all): New functions. * src/inetd.c (inetd_conf_file): Don't register prog right away. This is done later in component_config_commit. (inetd_parse_conf): Rename to inetd_config_parse. * src/limits.c (limits_cmp): New function. * src/pies.c (config_file): Replace with struct config_syntax. (str_to_config_syntax): Return a pointer to struct config_syntax. (add_config): Rename to config_file_add. (config_file_add_type): New function. (return_code_keywords, create_action): Change handling of actions. (return_code_section_parser): Likewise. (component_verify, component_create) (component_free, component_finish): Move to comp.c (config_parse): Remove. (pies_config_parse): New function. (pies_read_config,pies_reload): New function. (pies_reload): Rename to request_reload. (pies_status): Rename to request_status. (pies_stop): Rename to request_stop. (main): Change configuration file handling. SIGHUP reloads configuration, instead of restarting the program. (default_sigv,sig_handler): Handle SIGUSR1. * src/pies.h (component): New members: prev, next, listidx, arridx, ref_count, prog. Remove act_head, act_tail, act_temp. Add new prototypes. * src/prog.h (prog): Remove tag and prereq. * src/progman.c (prog_tag): New function. (destroy_prog): Update component reference count. (register_redir): Likewise. (register_prog0): Take one argument. Update component reference count. (register_prog): Update comp->prog (prog_rebuild_prerequisites): Remove. (component_fixup_depend): Remove. (fixup_prerequisites,rebuild_prerequisites) (print_dep,progman_dump_prereq) (progman_dump_depmap,progman_build_depmap): Remove. (prog_start_prerequisites): Scan depmap to find prerequisites. (prog_stop_dependents): Likewise. (progman_wait): Remove. (progman_wait_until): New function. (progman_stop): Rewrite using progman_wait_until. (react): Rewrite using grecs_list * src/sysvinit.c: Use prog_tag when needed. * src/userprivs.c (pies_privs_cmp, pies_privs_free): New functions. * grecs: Update. * lib/safe_strcmp.c: New file. * lib/Makefile.am: Add safe_strcmp.c * lib/libpies.h (safe_strcmp): New proto.
2016-01-10Improvements in init modeSergey Poznyakoff1
* src/progman.c (print_status): Suppress output if running as init process, unless in debug mode. * src/sysvinit.c (sysvinit_begin): Set up "non-failing" memory allocation.
2016-01-08Uniformly use grecs memory management functions.Sergey Poznyakoff1
* gnulib.modules: Remove unneded modules. * ident/ident.h: Remove xalloc.h, include errno.h * ident/ident.c: Use standard allocation functions instead of x* * ident/pam.c: Remove. * ident/provider.c: Remove. * ident/system.c: Remove. * src/meta.c: Remove. * src/Makefile.am: Remove meta.c * src/progman.c: Use grecs_* allocation functions instead of x*. (notify): Use wordsplit to expand variables within message. Rename variables: program-name to program_name; canonical-program-name to canonical_program_name. * doc/pies.texi: Update. * src/depmap.c: Use grecs_* allocation functions instead of x*. (depmap_end): New function. * src/diag.c (logmsg_vprintf): Use grecs_txtacc instead of obstack. * src/pies.h (depmap_end): New proto. Remove unused includes. * src/acl.c: Use grecs_* allocation functions instead of x*. * src/ctl.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise. * src/userprivs.c: Likewise.
2015-12-20Bugfixes in init modeSergey Poznyakoff1
* src/ctl.c (ctl_open): Add missing return. * src/pies.c (config_parse): Return if tree is null. (main) [INIT_EMU]: Print more info. Override default init_fifo. Don't use syslog and control socket if running as init process. * src/pies.h (init_fifo): New extern. * src/progman.c (open_redirector): Return -1 if running as init process. (prog_start): Always initialize redir[]. * src/sysvinit.c (init_fifo): New variable. Use it instead if the INIT_FIFO macro. (inittrans): Call create_fifo once, when transiting from boot to normal state.
2015-12-16Minor fixes.Sergey Poznyakoff1
* grecs: Upgrade. * lib/parsetime.c: Fix senseless compiler warnings. * src/acl.c: Fix docstrings. * src/meta1gram.y (yyerror): Change argument * src/meta1lex.l: Add flex options * src/pies.h (meta1error): Change signature. * src/progman.c (prog_lookup_by_socket): Remove. * src/sysvinit.c (sysvinit_stop_filter): Remove.
2015-10-31control socket: list typesSergey Poznyakoff1
* src/ctl.c: list prog types and search on them * src/progman.c (progman_foreach): Iterate over all elements, not only components. * src/sysvinit.c (runlevel_setup_prog): Check if prog is a component.
2015-10-30Introduce control connection.Sergey Poznyakoff1
* src/ctl.c: New file. * src/Makefile.am (pies_SOURCES): Add ctl.c * src/pies.c: New configuration statement "control" * src/pies.h (instance, ctl_url): New externs. (register_socket): Change signature. (update_socket,ctl_open): New protos. * src/socket.c (listenset): Remove. (fdset): New static. (sockinst)<handler>: Array of three pointers: handlers for read, write, and exception, correspondingly. (find_socket_handler): Remove. (register_socket): Take three function pointers as arguments. Update corresponding elements of fdset. (update_socket): New function. (pies_pause): Handle all three I/O operations. (deregister_socket) (register_program_socket) (disable_socket,enable_socket): Reflect the changes. * src/sysvinit.c (create_fifo): Update call to register_socket.
2014-12-27Minor fixes.Sergey Poznyakoff1
* lib/proctitle.c (mf_proctitle_format): Check return from vasprintf instead of checking the return pointer. * src/inetd-bi.c: Check return values from write where reasonable. * src/progman.c (redirect_to_file): Check return from chown. (close_fds): Fix coredump (upper boundary was wrong). (open_redirector, progman_dump_stats): Check return values. * src/sysvinit.c (sysvinit_setenv): Remove unused variable. * src/userprivs.c (str_eq, str_dispose): Remove unused functions. * src/utmp.c: Check return values.
2014-06-11Init emulator mode; bugfix.Sergey Poznyakoff1
* src/pies.c (main) [INIT_EMU]: Enable "init emulator" mode. * src/sysvinit.c (enablecomp) (sysvinit_runlevel_setup): Use struct enstate to pass information to the callback. This fixes bug introduced by the previous commit, which caused "wait" keyword to be ignored.
2014-06-09Implement ctrlaltdel and kbrequest processes.Sergey Poznyakoff1
* src/sysdep.c: New file. * src/Makefile.am (pies_SOURCES): Add sysdep.c * src/pies.c (ACTION_*): Move to pies.h (sig_handler): Call sysvinit_sigtrans, return immediately if it handles the signal. (setsigvhan): New function. (add_extra_sigv): New function. (signal_setup): Rewrite. (main): Handle ACTION_CTRLALTDEL and ACTION_KBREQUEST. * src/pies.h (PIES_COMP_DEFAULT) (PIES_COMP_WAIT,PIES_COMP_MASK): New defines. (pies_action): New enum, add new actions: ACTION_CTRLALTDEL and ACTION_KBREQUEST. (setsigvhan, add_extra_sigv) (sysvinit_sigtrans,sysvinit_runlevel_setup) (sysvinit_sysdep_begin): New protos. (sysvinit_request) <pad>: Rename to data. * src/sysvinit.c (enablecomp): Change meaning of the data pointer. (sysvinit_runlevel_setup): Change signature. Remove static qualifier. All uses changed. (sysvinit_setenv): New static. (sysvinit_fifo_handler): Handle INIT_CMD_SETENV. (sysvinit_sigtrans): New function. (sysvinit_begin): Set up new signals. Call sysvinit_sysdep_begin.
2013-01-07Add function for parsing /etc/inittab.Sergey Poznyakoff1
* src/limits.c (free_limits): New function. * src/pies.c (config_syntax): Move to pies.h (config_syntax_tab): New type "inittab" (free_action,component_free): New functions. (component_finish): Call component_free to discard the failed component. (main): In sysvinit mode, default to reading two configuration files: /etc/inittab and /etc/pies.init. Don't exit on configuration errors in this mode. * src/pies.h (str_to_config_syntax) (add_config,free_redirector) (component_free,free_limits) (inittab_parse): New protos. * src/progman.c (free_redirector): New function. * src/sysvinit.c (inittab_parse): New function.
2013-01-07Fix sysvinit execution environment, simplify boot state system.Sergey Poznyakoff1
* src/pies.c (_cb_runlevels): Bugfix. (set_console_dev): Move to sysvinit.c * src/pies.h (progman_sysvinit_enable): Remove proto. (console_open, telinit): New protos. (sysvinit_environ_hint): New extern. * src/prog.h (prog_stop): New proto. * src/progman.c (env_concat): Bugfix. (env_concat): In sysvinit mode, apply sysvinit_environ_hint to the environment. (console_open, console_stty): Move to sysvinit.c * src/sysvinit.c (boot_state): Simplify state set. (getinitdefault, askrunlevel): New functions. (sysvinit_runlevel_setup): New function. (enablecomp): Change signature to match progman_foreach API. (sysvinit_begin): Prepare console, become a session leader, prepare environment. (inittrans): Call sysvinit_runlevel_setup * src/socket.c (calc_fd_max): Fix return type. * src/acl.c (acl_copy): Remove unused variable.
2013-01-06Fix runlevel transition algorithm, implement SysV-style fifo interface.Sergey Poznyakoff1
* src/prog.h: New file. * src/Makefile.am: Add new file. * src/cmdline.opt: New option --telinit (-T). * src/diag.c (vlogmsg): In sysvin it mode, write directly to the console. Close it when finished. * src/pies.c (_cb_initdefault, _cb_runlevels): Use is_valid_runlevel to check if the specified runlevels are ok. (main): In sysvinit mode, reset action to ACTION_CONT. * src/pies.h (progman_filter): New proto. (progman_accept,register_socket): Change signature. (deregister_socket): New proto. (register_program_socket): New proto. * src/progman.c: Move constant and adatatype definitions to prog.h (prog_stop): Remove static qualifier. (console_open): Likewise. (progman_accept): Use new socket API. (progman_stop): Correctly handle timeouts. (progman_foreach): New function. * src/socket.c: Register all sockets along with their handlers in a doubly-linked list. (sockinst): New struct. (register_socket,deregister_socket): New functions. (register_program_socket): New function. (pies_pause): Traverse the list to find which fd has changed. Use its registered handler to handle the event. * src/sysvinit.c: Include prog.h (is_valid_runlevel): New function. (sysvinit_fifo_handler,check_fifo): New static functions. (inittrans): Fix transition algorithm. (telinit): New function.
2013-01-05Write utmp/wtmp records in sysvinit mode.Sergey Poznyakoff1
* configure.ac: Check for utmp.h, utmpx.h * src/utmp.c: New file. * src/Makefile.am: Add utmp.c * src/pies.h (sysvinit_acct): New proto. * src/progman.c (prog_start, progman_cleanup): Call sysvinit_acct. * src/sysvinit.c (inittrans): Call sysvinit_acct. Set proctitle.
2013-01-04Fix sysvinit transition logic.Sergey Poznyakoff1
* src/pies.c (main): Call sysvinit_begin to initialize sysvinit subsystem. In the main loop, force wakeup if inittrans returns 1. * src/pies.h (is_sysvinit): Rewrite macro. (progman_sysvinit_enable): New proto. (inittrans): Change return type. * src/progman.c (progman_sysvinit_enable): New function. (progman_running_p): Additional debugging. (prog_start): Special handling for sysvinit components. Remove calls to runlevel_match * src/sysvinit.c (runlevel_match): Remove function. (sysvinit_begin): New function. (inittrans): Return boolean value indicating whether a transition has been made. Call progman_sysvinit_enable to change the status of sysvinit components as appropriate.
2013-01-04Minor fixes.Sergey Poznyakoff1
* src/pies.c (modetab): Discern between "wait" and "respawn". * src/progman.c (progman_cleanup): Mark a terminated sysvinit component as status_finished.
2013-01-04Implement runlevel transitions.Sergey Poznyakoff1
* src/sysvinit.c: New file. * src/Makefile.am: Add new file. * src/pies.c (initdefault, dfl_level): Move to sysvinit.c (modetab): Add new modes. (inittrans): Move to sysvinit.c * src/pies.h (is_sysvinit): New macro. (dfl_level): New extern. (runlevel_match, inittrans, is_comp_wait): New protos. * src/progman.c (progman_running_p): Take into account only components. Use is_comp_wait to determine if the component should be waited for. (prog_start): Run sysvinit components only when started as init process. (runlevel_match): Move to sysvinit.c (prog_start_prerequisites): Return immediately if the component is disabled.

Return to:

Send suggestions and report system problems to the System administrator.