diff -up init/control.c.old init/control.c --- init/control.c.old 2009-06-22 11:59:11.000000000 +0200 +++ init/control.c 2009-06-22 11:59:26.000000000 +0200 @@ -43,6 +43,7 @@ #include #include "job.h" +#include "tty.h" #include "control.h" #include "notify.h" @@ -57,6 +58,11 @@ static int control_log_priority ( static int control_job_find (void *data, pid_t pid, UpstartMessageType type, const char *pattern); +static int control_push_tty (void *data, pid_t pid, + UpstartMessageType type, + const char *device); +static int control_pop_tty (void *data, pid_t pid, + UpstartMessageType type); static int control_job_query (void *data, pid_t pid, UpstartMessageType type, const char *name, unsigned int id); @@ -96,6 +102,10 @@ NihIo *control_io = NULL; static UpstartMessage message_handlers[] = { { -1, UPSTART_VERSION_QUERY, (UpstartMessageHandler)control_version_query }, + { -1, UPSTART_PUSH_TTY, + (UpstartMessageHandler)control_push_tty }, + { -1, UPSTART_POP_TTY, + (UpstartMessageHandler)control_pop_tty }, { -1, UPSTART_LOG_PRIORITY, (UpstartMessageHandler)control_log_priority }, { -1, UPSTART_JOB_FIND, @@ -308,6 +318,66 @@ control_send_instance (pid_t pid, nih_io_send_message (control_io, message); } +/** + * control_push_tty: + * @data: data pointer, + * @pid: origin process id, + * @type: message type received. + * + * This function is called to change the current tty. + * + * Returns: zero on success, negative value on raised error. + **/ +static int +control_push_tty (void *data, + pid_t pid, + UpstartMessageType type, + const char *device) +{ + NihIoMessage *reply; + + nih_assert (pid > 0); + nih_assert (type == UPSTART_PUSH_TTY); + + nih_info (_("Control request to change tty")); + + NIH_MUST (reply = upstart_message_new (control_io, pid, + UPSTART_TTY, + push_tty (device))); + nih_io_send_message (control_io, reply); + + return 0; +} + +/** + * control_pop_tty: + * @data: data pointer, + * @pid: origin process id, + * @type: message type received. + * + * This function is called to revert the most recent tty change. + * + * Returns: zero on success, negative value on raised error. + **/ +static int +control_pop_tty (void *data, + pid_t pid, + UpstartMessageType type) +{ + NihIoMessage *reply; + + nih_assert (pid > 0); + nih_assert (type == UPSTART_POP_TTY); + + nih_info (_("Control request to revert changed tty")); + + NIH_MUST (reply = upstart_message_new (control_io, pid, + UPSTART_TTY, + pop_tty ())); + nih_io_send_message (control_io, reply); + + return 0; +} /** * control_version_query: diff -up init/main.c.old init/main.c --- init/main.c.old 2009-06-22 13:42:44.000000000 +0200 +++ init/main.c 2009-06-22 13:42:55.000000000 +0200 @@ -58,6 +58,7 @@ #include "control.h" #include "cfgfile.h" #include "paths.h" +#include "tty.h" /* Prototypes for static functions */ @@ -190,6 +191,8 @@ main (int argc, if (! (restart || rescue)) reset_console (); + tty_stack_init (); + /* Set the PATH environment variable */ setenv ("PATH", PATH, TRUE); diff -up init/Makefile.in.old init/Makefile.in --- init/Makefile.in.old 2009-06-22 11:56:34.000000000 +0200 +++ init/Makefile.in 2009-06-22 11:56:53.000000000 +0200 @@ -72,9 +72,9 @@ am__EXEEXT_1 = test_process$(EXEEXT) tes am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)" sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(sbin_PROGRAMS) -am_init_OBJECTS = main.$(OBJEXT) process.$(OBJEXT) job.$(OBJEXT) \ - event.$(OBJEXT) control.$(OBJEXT) notify.$(OBJEXT) \ - cfgfile.$(OBJEXT) +am_init_OBJECTS = main.$(OBJEXT) tty.$(OBJEXT) process.$(OBJEXT) \ + job.$(OBJEXT) event.$(OBJEXT) control.$(OBJEXT) \ + notify.$(OBJEXT) cfgfile.$(OBJEXT) init_OBJECTS = $(am_init_OBJECTS) am__DEPENDENCIES_1 = init_DEPENDENCIES = ../upstart/libupstart.la ../nih/libnih.la \ @@ -314,6 +314,7 @@ dist_man_MANS = \ init_SOURCES = \ main.c \ + tty.c tty.h\ errors.h paths.h \ process.c process.h \ job.c job.h \ @@ -474,6 +475,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_job.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_notify.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_process.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tty.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff -up init/process.c.old init/process.c --- init/process.c.old 2009-06-22 13:45:48.000000000 +0200 +++ init/process.c 2009-06-22 13:45:48.000000000 +0200 @@ -51,6 +51,7 @@ #include "job.h" #include "process.h" #include "paths.h" +#include "tty.h" /* Prototypes for static functions */ @@ -385,10 +386,11 @@ process_setup_console (Job *job, break; - case CONSOLE_OUTPUT: + case CONSOLE_OUTPUT: { /* Ordinary console input and output */ - fd = open (CONSOLE, O_RDWR | O_NOCTTY); + fd = open (current_tty (), O_RDWR | O_NOCTTY); break; + } case CONSOLE_OWNER: /* As CONSOLE_OUTPUT but with ^C, etc. sent */ diff -up init/tty.c.old init/tty.c --- init/tty.c.old 2009-06-22 13:45:48.000000000 +0200 +++ init/tty.c 2009-06-22 13:45:48.000000000 +0200 @@ -0,0 +1,97 @@ +/* upstart + * + * tty.c - tty change events + * + * Copyright © 2007 Canonical Ltd. + * Author: Scott James Remnant . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "paths.h" + +static char **tty_stack = NULL; +static size_t tty_stack_top = 0; + +/** + * tty_stack_init: + * + * Allocate the tty stack + **/ +void +tty_stack_init (void) +{ + NIH_MUST (tty_stack = nih_str_array_new (NULL)); +} + +/** + * current_tty: + * + * Get the tty at the top of the stack + **/ +const char * +current_tty (void) +{ + if (!tty_stack_top) return CONSOLE; + return tty_stack[tty_stack_top - 1]; +} + +/** + * tty_stack_init: + * + * Push a tty onto the tty stack + **/ +const char * +push_tty (const char *tty) +{ + nih_assert (tty_stack != NULL); + NIH_MUST (nih_str_array_add (&tty_stack, NULL, &tty_stack_top, tty)); + + return current_tty (); +} + +/** + * pop_tty: + * + * Pop a tty off of the tty stack + **/ +const char * +pop_tty (void) +{ + nih_assert (tty_stack != NULL); + if (tty_stack_top == 0) return current_tty(); + nih_free (tty_stack[tty_stack_top - 1]); + tty_stack[--tty_stack_top] = NULL; + tty_stack = nih_realloc (tty_stack, NULL, + sizeof (char *) * (tty_stack_top + 2)); + + return current_tty (); +} + diff -up init/tty.h.old init/tty.h --- init/tty.h.old 2009-06-22 13:45:48.000000000 +0200 +++ init/tty.h 2009-06-22 13:45:48.000000000 +0200 @@ -0,0 +1,35 @@ +/* upstart + * + * Copyright © 2007 Canonical Ltd. + * Author: Scott James Remnant . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INIT_TTY_H +#define INIT_TTY_H + +#include + +NIH_BEGIN_EXTERN + +const char *current_tty (void); +const char *push_tty (const char *tty); +const char *pop_tty (void); +void tty_stack_init (void); + +NIH_END_EXTERN + +#endif /* INIT_TTY_H */ diff -up po/ca.po.old po/ca.po --- po/ca.po.old 2009-06-22 13:45:48.000000000 +0200 +++ po/ca.po 2009-06-22 13:45:48.000000000 +0200 @@ -22,46 +22,46 @@ msgstr "" msgid "display list of commands" msgstr "mostra aquesta ajuda i surt" -#: nih/command.c:141 +#: nih/command.c:139 #, c-format msgid "For a list of commands, try `%s help'." msgstr "" -#: nih/command.c:144 +#: nih/command.c:142 msgid "COMMAND [OPTION]... [ARG]..." msgstr "" -#: nih/command.c:162 +#: nih/command.c:160 #, fuzzy, c-format msgid "%s: missing command\n" msgstr "%s: manca un argument: %s\n" -#: nih/command.c:170 +#: nih/command.c:168 #, fuzzy, c-format msgid "%s: invalid command: %s\n" msgstr "%s: l'opció és invàlida: --%s\n" -#: nih/command.c:181 +#: nih/command.c:179 #, c-format msgid "%s [OPTION]..." msgstr "" -#: nih/command.c:424 +#: nih/command.c:418 #, c-format msgid "For more information on a command, try `%s COMMAND --help'.\n" msgstr "" -#: nih/command.c:450 +#: nih/command.c:444 #, fuzzy, c-format msgid "%s commands:\n" msgstr "Opcions %s:\n" -#: nih/command.c:452 +#: nih/command.c:446 #, fuzzy, c-format msgid "Other commands:\n" msgstr "Altres opcions:\n" -#: nih/command.c:454 +#: nih/command.c:448 #, c-format msgid "Commands:\n" msgstr "" @@ -70,7 +70,7 @@ msgstr "" msgid "Unhandled Error" msgstr "Error no gestionat" -#: nih/io.c:1203 +#: nih/io.c:1198 msgid "Error while reading from descriptor" msgstr "S'ha produït un error en llegir del descriptor" @@ -101,60 +101,60 @@ msgstr "mostra aquesta ajuda i surt" msgid "output version information and exit" msgstr "mostra la informació sobre la versió i surt" -#: nih/option.c:299 +#: nih/option.c:297 #, c-format msgid "%s: invalid option: -%c\n" msgstr "%s: l'opció és invàlida: -%c\n" -#: nih/option.c:392 +#: nih/option.c:390 #, c-format msgid "%s: invalid option: --%s\n" msgstr "%s: l'opció és invàlida: --%s\n" -#: nih/option.c:408 +#: nih/option.c:406 #, c-format msgid "%s: unexpected argument: --%s\n" msgstr "%s: no s'esperava l'argument: --%s\n" -#: nih/option.c:464 +#: nih/option.c:462 #, c-format msgid "%s: missing argument: %s\n" msgstr "%s: manca un argument: %s\n" -#: nih/option.c:664 +#: nih/option.c:660 #, fuzzy, c-format msgid "%s: illegal argument: %s\n" msgstr "%s: manca un argument: %s\n" -#: nih/option.c:862 +#: nih/option.c:858 msgid "Usage" msgstr "Forma d'ús" -#: nih/option.c:866 +#: nih/option.c:862 msgid "[OPTION]..." msgstr "" -#: nih/option.c:915 +#: nih/option.c:911 #, c-format msgid "Report bugs to <%s>\n" msgstr "Informeu-ne del errors a <%s>\n" -#: nih/option.c:941 +#: nih/option.c:937 #, c-format msgid "%s options:\n" msgstr "Opcions %s:\n" -#: nih/option.c:943 +#: nih/option.c:939 #, c-format msgid "Other options:\n" msgstr "Altres opcions:\n" -#: nih/option.c:945 +#: nih/option.c:941 #, c-format msgid "Options:\n" msgstr "Opcions:\n" -#: nih/watch.c:521 +#: nih/watch.c:560 msgid "Unable to watch directory" msgstr "" @@ -305,82 +305,92 @@ msgstr "" msgid "Deleting %s job" msgstr "S'està tornant a exiecutar %s" -#: init/control.c:216 +#: init/control.c:225 #, fuzzy, c-format msgid "Error on control socket: %s" msgstr "S'ha produït un error en llegir el missatge de control: %s" -#: init/control.c:336 +#: init/control.c:345 +#, fuzzy +msgid "Control request to change tty" +msgstr "Petició de control per a iniciar %s" + +#: init/control.c:379 +#, fuzzy +msgid "Control request to revert changed tty" +msgstr "Petició de control per a iniciar %s" + +#: init/control.c:413 #, fuzzy msgid "Control request for our version" msgstr "Petició de control per a consultar l'estat de %s" -#: init/control.c:369 +#: init/control.c:446 #, fuzzy msgid "Control request to change logging priority" msgstr "Petició de control per a iniciar %s" -#: init/control.c:406 +#: init/control.c:483 #, fuzzy, c-format msgid "Control request for jobs matching %s" msgstr "Petició de control per a consultar l'estat de %s" -#: init/control.c:408 +#: init/control.c:485 #, fuzzy msgid "Control request for all jobs" msgstr "Petició de control per a consultar l'estat de %s" -#: init/control.c:470 +#: init/control.c:547 #, fuzzy, c-format msgid "Control request for status of %s" msgstr "Petició de control per a consultar l'estat de %s" -#: init/control.c:474 +#: init/control.c:551 #, fuzzy, c-format msgid "Control request for status of job #%u" msgstr "Petició de control per a consultar l'estat de %s" -#: init/control.c:528 +#: init/control.c:605 #, c-format msgid "Control request to start %s" msgstr "Petició de control per a iniciar %s" -#: init/control.c:532 +#: init/control.c:609 #, fuzzy, c-format msgid "Control request to start job #%u" msgstr "Petició de control per a iniciar %s" -#: init/control.c:615 +#: init/control.c:692 #, c-format msgid "Control request to stop %s" msgstr "Petició de control per a aturar %s" -#: init/control.c:619 +#: init/control.c:696 #, fuzzy, c-format msgid "Control request to stop job #%u" msgstr "Petició de control per a aturar %s" -#: init/control.c:748 +#: init/control.c:825 #, fuzzy, c-format msgid "Control request to emit %s event" msgstr "Petició de control per a aturar %s" -#: init/control.c:779 +#: init/control.c:856 #, c-format msgid "Control request to subscribe %d to jobs" msgstr "Petició de control per a subscriure %d als treballs" -#: init/control.c:810 +#: init/control.c:887 #, c-format msgid "Control request to unsubscribe %d from jobs" msgstr "Petició de control per a desubscriure %d dels treballs" -#: init/control.c:840 +#: init/control.c:917 #, c-format msgid "Control request to subscribe %d to events" msgstr "" -#: init/control.c:871 +#: init/control.c:948 #, c-format msgid "Control request to unsubscribe %d from events" msgstr "" @@ -485,7 +495,7 @@ msgid "" "actually run /sbin/telinit." msgstr "" -#: init/main.c:136 util/initctl.c:366 compat/sysv/reboot.c:203 +#: init/main.c:136 util/initctl.c:373 compat/sysv/reboot.c:203 #: compat/sysv/shutdown.c:322 compat/sysv/telinit.c:91 msgid "Need to be root" msgstr "Es necessita ser root" @@ -657,6 +667,11 @@ msgstr "%s: l'opció és invàlida: --%s msgid "%s: missing job name\n" msgstr "" +#: util/initctl.c:1889 +#, fuzzy, c-format +msgid "%s: missing device name\n" +msgstr "%s: manca un argument: %s\n" + #: util/initctl.c:1826 #, c-format msgid "%s: missing event name\n" @@ -733,11 +748,11 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2119 +#: util/initctl.c:2239 msgid "Stop jobs." msgstr "" -#: util/initctl.c:2120 +#: util/initctl.c:2240 msgid "" "JOB is one or more job names that are to be stopped.\n" "\n" @@ -745,11 +760,11 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2126 +#: util/initctl.c:2246 msgid "Query status of jobs." msgstr "" -#: util/initctl.c:2127 +#: util/initctl.c:2247 msgid "" "JOB is one or more job names that are to be queried.\n" "\n" @@ -757,19 +772,19 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2133 +#: util/initctl.c:2253 msgid "List known jobs." msgstr "" -#: util/initctl.c:2137 +#: util/initctl.c:2257 msgid "EVENT [ARG]..." msgstr "" -#: util/initctl.c:2138 +#: util/initctl.c:2258 msgid "Emit an event." msgstr "" -#: util/initctl.c:2139 +#: util/initctl.c:2259 msgid "" "EVENT is the name of an event the init daemon should emit, which may have " "zero or more arguments specified by ARG. These may be matched in the job " @@ -780,27 +795,35 @@ msgid "" "taken from the environment or ignored if not present there." msgstr "" -#: util/initctl.c:2150 +#: util/initctl.c:2270 msgid "Receive notification of job state changes." msgstr "" -#: util/initctl.c:2155 +#: util/initctl.c:2275 msgid "Receive notification of emitted events." msgstr "" -#: util/initctl.c:2160 +#: util/initctl.c:2280 +msgid "Change the init daemon's tty device" +msgstr "" + +#: util/initctl.c:2285 +msgid "Revert the last change to the init daemon's tty device" +msgstr "" + +#: util/initctl.c:2290 msgid "Request the version of the init daemon." msgstr "" -#: util/initctl.c:2163 +#: util/initctl.c:2293 msgid "PRIORITY" msgstr "" -#: util/initctl.c:2164 +#: util/initctl.c:2294 msgid "Change the minimum priority of log messages from the init daemon" msgstr "" -#: util/initctl.c:2166 +#: util/initctl.c:2296 msgid "" "PRIORITY may be one of `debug' (messages useful for debugging upstart are " "logged, equivalent to --debug on kernel command-line); `info' (messages " diff -up po/fr.po.old po/fr.po --- po/fr.po.old 2009-06-22 13:45:48.000000000 +0200 +++ po/fr.po 2009-06-22 13:45:48.000000000 +0200 @@ -22,46 +22,46 @@ msgstr "" msgid "display list of commands" msgstr "afficher cette aide et quitter" -#: nih/command.c:141 +#: nih/command.c:139 #, c-format msgid "For a list of commands, try `%s help'." msgstr "" -#: nih/command.c:144 +#: nih/command.c:142 msgid "COMMAND [OPTION]... [ARG]..." msgstr "" -#: nih/command.c:162 +#: nih/command.c:160 #, fuzzy, c-format msgid "%s: missing command\n" msgstr "%s : argument manquant : %s\n" -#: nih/command.c:170 +#: nih/command.c:168 #, fuzzy, c-format msgid "%s: invalid command: %s\n" msgstr "%s : option invalide : --%s\n" -#: nih/command.c:181 +#: nih/command.c:179 #, c-format msgid "%s [OPTION]..." msgstr "" -#: nih/command.c:424 +#: nih/command.c:418 #, c-format msgid "For more information on a command, try `%s COMMAND --help'.\n" msgstr "" -#: nih/command.c:450 +#: nih/command.c:444 #, fuzzy, c-format msgid "%s commands:\n" msgstr "%s options:\n" -#: nih/command.c:452 +#: nih/command.c:446 #, fuzzy, c-format msgid "Other commands:\n" msgstr "Autres options:\n" -#: nih/command.c:454 +#: nih/command.c:448 #, c-format msgid "Commands:\n" msgstr "" @@ -70,7 +70,7 @@ msgstr "" msgid "Unhandled Error" msgstr "Erreur non traitée" -#: nih/io.c:1203 +#: nih/io.c:1198 #, fuzzy msgid "Error while reading from descriptor" msgstr "Erreur lors de la lecture du descripteur" @@ -106,60 +106,60 @@ msgstr "afficher cette aide et quitter" msgid "output version information and exit" msgstr "affichage de l'information de version et sortie" -#: nih/option.c:299 +#: nih/option.c:297 #, c-format msgid "%s: invalid option: -%c\n" msgstr "%s: option ivalide: -%c\n" -#: nih/option.c:392 +#: nih/option.c:390 #, c-format msgid "%s: invalid option: --%s\n" msgstr "%s : option invalide : --%s\n" -#: nih/option.c:408 +#: nih/option.c:406 #, c-format msgid "%s: unexpected argument: --%s\n" msgstr "%s : argument inattendu : --%s\n" -#: nih/option.c:464 +#: nih/option.c:462 #, c-format msgid "%s: missing argument: %s\n" msgstr "%s : argument manquant : %s\n" -#: nih/option.c:664 +#: nih/option.c:660 #, fuzzy, c-format msgid "%s: illegal argument: %s\n" msgstr "%s : argument manquant : %s\n" -#: nih/option.c:862 +#: nih/option.c:858 msgid "Usage" msgstr "Utilisation" -#: nih/option.c:866 +#: nih/option.c:862 msgid "[OPTION]..." msgstr "" -#: nih/option.c:915 +#: nih/option.c:911 #, c-format msgid "Report bugs to <%s>\n" msgstr "Signalez les anomalies à <%s>\n" -#: nih/option.c:941 +#: nih/option.c:937 #, c-format msgid "%s options:\n" msgstr "%s options:\n" -#: nih/option.c:943 +#: nih/option.c:939 #, c-format msgid "Other options:\n" msgstr "Autres options:\n" -#: nih/option.c:945 +#: nih/option.c:941 #, c-format msgid "Options:\n" msgstr "Options:\n" -#: nih/watch.c:521 +#: nih/watch.c:560 #, fuzzy msgid "Unable to watch directory" msgstr "Impossible d'accepter la connexion : %s" @@ -315,82 +315,92 @@ msgstr "Impossible d'accepter la connexi msgid "Deleting %s job" msgstr "Ré-éxecution de %s" -#: init/control.c:216 +#: init/control.c:225 #, fuzzy, c-format msgid "Error on control socket: %s" msgstr "Erreur lors de la lecture du message de contrôle : %s" -#: init/control.c:336 +#: init/control.c:345 +#, fuzzy +msgid "Control request to change tty" +msgstr "Demande de contrôle à commencer %s" + +#: init/control.c:379 +#, fuzzy +msgid "Control request to revert changed tty" +msgstr "Demande de contrôle à commencer %s" + +#: init/control.c:413 #, fuzzy msgid "Control request for our version" msgstr "Demande de contrôle pour lister les tâches" -#: init/control.c:369 +#: init/control.c:446 #, fuzzy msgid "Control request to change logging priority" msgstr "Demande de contrôle à commencer %s" -#: init/control.c:406 +#: init/control.c:483 #, fuzzy, c-format msgid "Control request for jobs matching %s" msgstr "Demande de contrôle de status pour %s" -#: init/control.c:408 +#: init/control.c:485 #, fuzzy msgid "Control request for all jobs" msgstr "Demande de contrôle pour lister les tâches" -#: init/control.c:470 +#: init/control.c:547 #, fuzzy, c-format msgid "Control request for status of %s" msgstr "Demande de contrôle de status pour %s" -#: init/control.c:474 +#: init/control.c:551 #, fuzzy, c-format msgid "Control request for status of job #%u" msgstr "Demande de contrôle de status pour %s" -#: init/control.c:528 +#: init/control.c:605 #, fuzzy, c-format msgid "Control request to start %s" msgstr "Demande de contrôle à commencer %s" -#: init/control.c:532 +#: init/control.c:609 #, fuzzy, c-format msgid "Control request to start job #%u" msgstr "Demande de contrôle à commencer %s" -#: init/control.c:615 +#: init/control.c:692 #, fuzzy, c-format msgid "Control request to stop %s" msgstr "Demande de contrôle pour arreter %s" -#: init/control.c:619 +#: init/control.c:696 #, fuzzy, c-format msgid "Control request to stop job #%u" msgstr "Demande de contrôle pour arreter %s" -#: init/control.c:748 +#: init/control.c:825 #, fuzzy, c-format msgid "Control request to emit %s event" msgstr "Demande de contrôle pour faire la queue des évènements %s" -#: init/control.c:779 +#: init/control.c:856 #, fuzzy, c-format msgid "Control request to subscribe %d to jobs" msgstr "Demande de contrôle pour inscrire %d aux tâches" -#: init/control.c:810 +#: init/control.c:887 #, fuzzy, c-format msgid "Control request to unsubscribe %d from jobs" msgstr "Demande de contrôle pour désinscrire % des tâches" -#: init/control.c:840 +#: init/control.c:917 #, fuzzy, c-format msgid "Control request to subscribe %d to events" msgstr "Demande de contrôle pour inscrire %d aux évènements" -#: init/control.c:871 +#: init/control.c:948 #, fuzzy, c-format msgid "Control request to unsubscribe %d from events" msgstr "Demande de contrôle pour désinscrire %d des évènements" @@ -496,7 +506,7 @@ msgid "" "actually run /sbin/telinit." msgstr "" -#: init/main.c:136 util/initctl.c:366 compat/sysv/reboot.c:203 +#: init/main.c:136 util/initctl.c:373 compat/sysv/reboot.c:203 #: compat/sysv/shutdown.c:322 compat/sysv/telinit.c:91 #, fuzzy msgid "Need to be root" @@ -672,6 +682,11 @@ msgstr "%s : option invalide : --%s\n" msgid "%s: missing job name\n" msgstr "" +#: util/initctl.c:1889 +#, fuzzy, c-format +msgid "%s: missing device name\n" +msgstr "%s: argument manquant : %s\n" + #: util/initctl.c:1826 #, c-format msgid "%s: missing event name\n" @@ -748,11 +763,11 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2119 +#: util/initctl.c:2239 msgid "Stop jobs." msgstr "" -#: util/initctl.c:2120 +#: util/initctl.c:2240 msgid "" "JOB is one or more job names that are to be stopped.\n" "\n" @@ -760,11 +775,11 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2126 +#: util/initctl.c:2246 msgid "Query status of jobs." msgstr "" -#: util/initctl.c:2127 +#: util/initctl.c:2247 msgid "" "JOB is one or more job names that are to be queried.\n" "\n" @@ -772,19 +787,19 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2133 +#: util/initctl.c:2253 msgid "List known jobs." msgstr "" -#: util/initctl.c:2137 +#: util/initctl.c:2257 msgid "EVENT [ARG]..." msgstr "" -#: util/initctl.c:2138 +#: util/initctl.c:2258 msgid "Emit an event." msgstr "" -#: util/initctl.c:2139 +#: util/initctl.c:2259 msgid "" "EVENT is the name of an event the init daemon should emit, which may have " "zero or more arguments specified by ARG. These may be matched in the job " @@ -795,27 +810,35 @@ msgid "" "taken from the environment or ignored if not present there." msgstr "" -#: util/initctl.c:2150 +#: util/initctl.c:2270 msgid "Receive notification of job state changes." msgstr "" -#: util/initctl.c:2155 +#: util/initctl.c:2275 msgid "Receive notification of emitted events." msgstr "" -#: util/initctl.c:2160 +#: util/initctl.c:2280 +msgid "Change the init daemon's tty device" +msgstr "" + +#: util/initctl.c:2285 +msgid "Revert the last change to the init daemon's tty device" +msgstr "" + +#: util/initctl.c:2290 msgid "Request the version of the init daemon." msgstr "" -#: util/initctl.c:2163 +#: util/initctl.c:2293 msgid "PRIORITY" msgstr "" -#: util/initctl.c:2164 +#: util/initctl.c:2294 msgid "Change the minimum priority of log messages from the init daemon" msgstr "" -#: util/initctl.c:2166 +#: util/initctl.c:2296 msgid "" "PRIORITY may be one of `debug' (messages useful for debugging upstart are " "logged, equivalent to --debug on kernel command-line); `info' (messages " diff -up po/sv.po.old po/sv.po --- po/sv.po.old 2009-06-22 13:45:48.000000000 +0200 +++ po/sv.po 2009-06-22 13:45:48.000000000 +0200 @@ -21,46 +21,46 @@ msgstr "" msgid "display list of commands" msgstr "" -#: nih/command.c:141 +#: nih/command.c:139 #, c-format msgid "For a list of commands, try `%s help'." msgstr "" -#: nih/command.c:144 +#: nih/command.c:142 msgid "COMMAND [OPTION]... [ARG]..." msgstr "" -#: nih/command.c:162 +#: nih/command.c:160 #, c-format msgid "%s: missing command\n" msgstr "" -#: nih/command.c:170 +#: nih/command.c:168 #, c-format msgid "%s: invalid command: %s\n" msgstr "" -#: nih/command.c:181 +#: nih/command.c:179 #, c-format msgid "%s [OPTION]..." msgstr "" -#: nih/command.c:424 +#: nih/command.c:418 #, c-format msgid "For more information on a command, try `%s COMMAND --help'.\n" msgstr "" -#: nih/command.c:450 +#: nih/command.c:444 #, c-format msgid "%s commands:\n" msgstr "" -#: nih/command.c:452 +#: nih/command.c:446 #, c-format msgid "Other commands:\n" msgstr "" -#: nih/command.c:454 +#: nih/command.c:448 #, c-format msgid "Commands:\n" msgstr "" @@ -69,7 +69,7 @@ msgstr "" msgid "Unhandled Error" msgstr "" -#: nih/io.c:1203 +#: nih/io.c:1198 msgid "Error while reading from descriptor" msgstr "" @@ -100,60 +100,60 @@ msgstr "" msgid "output version information and exit" msgstr "" -#: nih/option.c:299 +#: nih/option.c:297 #, c-format msgid "%s: invalid option: -%c\n" msgstr "" -#: nih/option.c:392 +#: nih/option.c:390 #, c-format msgid "%s: invalid option: --%s\n" msgstr "" -#: nih/option.c:408 +#: nih/option.c:406 #, c-format msgid "%s: unexpected argument: --%s\n" msgstr "" -#: nih/option.c:464 +#: nih/option.c:462 #, c-format msgid "%s: missing argument: %s\n" msgstr "" -#: nih/option.c:664 +#: nih/option.c:660 #, c-format msgid "%s: illegal argument: %s\n" msgstr "" -#: nih/option.c:862 +#: nih/option.c:858 msgid "Usage" msgstr "" -#: nih/option.c:866 +#: nih/option.c:862 msgid "[OPTION]..." msgstr "" -#: nih/option.c:915 +#: nih/option.c:911 #, c-format msgid "Report bugs to <%s>\n" msgstr "" -#: nih/option.c:941 +#: nih/option.c:937 #, c-format msgid "%s options:\n" msgstr "" -#: nih/option.c:943 +#: nih/option.c:939 #, c-format msgid "Other options:\n" msgstr "" -#: nih/option.c:945 +#: nih/option.c:941 #, c-format msgid "Options:\n" msgstr "" -#: nih/watch.c:521 +#: nih/watch.c:560 msgid "Unable to watch directory" msgstr "" @@ -295,79 +295,87 @@ msgstr "" msgid "Deleting %s job" msgstr "" -#: init/control.c:216 +#: init/control.c:225 #, c-format msgid "Error on control socket: %s" msgstr "" -#: init/control.c:336 +#: init/control.c:345 +msgid "Control request to change tty" +msgstr "" + +#: init/control.c:379 +msgid "Control request to revert changed tty" +msgstr "" + +#: init/control.c:413 msgid "Control request for our version" msgstr "" -#: init/control.c:369 +#: init/control.c:446 msgid "Control request to change logging priority" msgstr "" -#: init/control.c:406 +#: init/control.c:483 #, c-format msgid "Control request for jobs matching %s" msgstr "" -#: init/control.c:408 +#: init/control.c:485 msgid "Control request for all jobs" msgstr "" -#: init/control.c:470 +#: init/control.c:547 #, c-format msgid "Control request for status of %s" msgstr "" -#: init/control.c:474 +#: init/control.c:551 #, c-format msgid "Control request for status of job #%u" msgstr "" -#: init/control.c:528 +#: init/control.c:605 #, c-format msgid "Control request to start %s" msgstr "" -#: init/control.c:532 +#: init/control.c:609 #, c-format msgid "Control request to start job #%u" msgstr "" -#: init/control.c:615 +#: init/control.c:692 #, c-format msgid "Control request to stop %s" msgstr "" -#: init/control.c:619 +#: init/control.c:696 #, c-format msgid "Control request to stop job #%u" msgstr "" -#: init/control.c:748 +#: init/control.c:825 #, c-format msgid "Control request to emit %s event" msgstr "" -#: init/control.c:779 +#: init/control.c:856 #, c-format msgid "Control request to subscribe %d to jobs" msgstr "" -#: init/control.c:810 +#: init/control.c:887 #, c-format msgid "Control request to unsubscribe %d from jobs" msgstr "" -#: init/control.c:840 +#: init/control.c:917 #, c-format msgid "Control request to subscribe %d to events" msgstr "" -#: init/control.c:871 +#: init/control.c:948 #, c-format msgid "Control request to unsubscribe %d from events" msgstr "" @@ -472,7 +480,7 @@ msgid "" "actually run /sbin/telinit." msgstr "" -#: init/main.c:136 util/initctl.c:366 compat/sysv/reboot.c:203 +#: init/main.c:136 util/initctl.c:373 compat/sysv/reboot.c:203 #: compat/sysv/shutdown.c:322 compat/sysv/telinit.c:91 msgid "Need to be root" msgstr "" @@ -642,6 +650,11 @@ msgstr "" msgid "%s: missing job name\n" msgstr "" +#: util/initctl.c:1889 +#, fuzzy, c-format +msgid "%s: missing device name\n" +msgstr "" + #: util/initctl.c:1826 #, c-format msgid "%s: missing event name\n" @@ -718,11 +731,11 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2119 +#: util/initctl.c:2239 msgid "Stop jobs." msgstr "" -#: util/initctl.c:2120 +#: util/initctl.c:2240 msgid "" "JOB is one or more job names that are to be stopped.\n" "\n" @@ -730,11 +743,11 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2126 +#: util/initctl.c:2246 msgid "Query status of jobs." msgstr "" -#: util/initctl.c:2127 +#: util/initctl.c:2247 msgid "" "JOB is one or more job names that are to be queried.\n" "\n" @@ -742,19 +755,19 @@ msgid "" "uniquely identifying a particular instance of a job." msgstr "" -#: util/initctl.c:2133 +#: util/initctl.c:2253 msgid "List known jobs." msgstr "" -#: util/initctl.c:2137 +#: util/initctl.c:2257 msgid "EVENT [ARG]..." msgstr "" -#: util/initctl.c:2138 +#: util/initctl.c:2258 msgid "Emit an event." msgstr "" -#: util/initctl.c:2139 +#: util/initctl.c:2259 msgid "" "EVENT is the name of an event the init daemon should emit, which may have " "zero or more arguments specified by ARG. These may be matched in the job " @@ -765,27 +778,35 @@ msgid "" "taken from the environment or ignored if not present there." msgstr "" -#: util/initctl.c:2150 +#: util/initctl.c:2270 msgid "Receive notification of job state changes." msgstr "" -#: util/initctl.c:2155 +#: util/initctl.c:2275 msgid "Receive notification of emitted events." msgstr "" -#: util/initctl.c:2160 +#: util/initctl.c:2280 +msgid "Change the init daemon's tty device" +msgstr "" + +#: util/initctl.c:2285 +msgid "Revert the last change to the init daemon's tty device" +msgstr "" + +#: util/initctl.c:2290 msgid "Request the version of the init daemon." msgstr "" -#: util/initctl.c:2163 +#: util/initctl.c:2293 msgid "PRIORITY" msgstr "" -#: util/initctl.c:2164 +#: util/initctl.c:2294 msgid "Change the minimum priority of log messages from the init daemon" msgstr "" -#: util/initctl.c:2166 +#: util/initctl.c:2296 msgid "" "PRIORITY may be one of `debug' (messages useful for debugging upstart are " "logged, equivalent to --debug on kernel command-line); `info' (messages " diff -up upstart/message.c.old upstart/message.c --- upstart/message.c.old 2009-06-22 13:45:48.000000000 +0200 +++ upstart/message.c 2009-06-22 13:45:48.000000000 +0200 @@ -261,6 +261,20 @@ upstart_message_newv (const void break; case UPSTART_VERSION_QUERY: break; + case UPSTART_POP_TTY: + break; + case UPSTART_TTY: + if (upstart_push_packv (message, "s", args_copy)) + goto error; + + break; + + case UPSTART_PUSH_TTY: + if (upstart_push_packv (message, "s", args_copy)) + goto error; + + break; + case UPSTART_LOG_PRIORITY: if (upstart_push_packv (message, "u", args_copy)) goto error; @@ -550,6 +564,9 @@ upstart_message_handle (const void * case UPSTART_VERSION_QUERY: ret = handler (data, cred.pid, type); break; + case UPSTART_POP_TTY: + ret = handler (data, cred.pid, type); + break; case UPSTART_LOG_PRIORITY: { NihLogLevel priority; @@ -559,6 +576,41 @@ upstart_message_handle (const void * ret = handler (data, cred.pid, type, priority); break; } + + case UPSTART_PUSH_TTY: { + char *tty = NULL; + + if (upstart_pop_pack (message, parent, "s", &tty)) { + if (tty) + nih_free (tty); + + goto invalid; + } + + if (! tty) + goto invalid; + + ret = handler (data, cred.pid, type, tty); + break; + } + + case UPSTART_TTY: { + char *tty = NULL; + + if (upstart_pop_pack (message, parent, "s", &tty)) { + if (tty) + nih_free (tty); + + goto invalid; + } + + if (! tty) + goto invalid; + + ret = handler (data, cred.pid, type, tty); + break; + } + case UPSTART_VERSION: { char *version = NULL; diff -up upstart/message.h.old upstart/message.h --- upstart/message.h.old 2009-06-22 13:45:48.000000000 +0200 +++ upstart/message.h 2009-06-22 13:45:48.000000000 +0200 @@ -57,11 +57,20 @@ typedef enum upstart_message_type { * UPSTART_VERSION message in reply. * * Clients may send UPSTART_LOG_PRIORITY, without any reply. + * + * Clients may send UPSTART_PUSH_TTY and recieve an UPSTART_TTY message + * in reply + * + * Clients may send UPSTART_POP_TTY and recieve an UPSTART_TTY message + * in reply */ UPSTART_NO_OP = 0x0000, UPSTART_VERSION_QUERY = 0x0001, UPSTART_LOG_PRIORITY = 0x0002, UPSTART_VERSION = 0x0010, + UPSTART_PUSH_TTY = 0x0011, + UPSTART_POP_TTY = 0x0012, + UPSTART_TTY = 0x0013, /* Job requests and responses. * diff -up util/initctl.c.old util/initctl.c --- util/initctl.c.old 2009-06-22 13:45:48.000000000 +0200 +++ util/initctl.c 2009-06-22 13:45:48.000000000 +0200 @@ -99,6 +99,9 @@ static void job_info_output (const JobI static char *output_name (unsigned int id, const char *name); /* Prototypes of response handler functions */ +static int handle_tty (void *data, pid_t pid, + UpstartMessageType type, + const char *tty); static int handle_version (void *data, pid_t pid, UpstartMessageType type, const char *version); @@ -159,6 +162,8 @@ static int handle_unknown_message (void /* Prototypes for option and command functions */ int env_option (NihOption *option, const char *arg); +int push_tty_action (NihCommand *command, char * const *args); +int pop_tty_action (NihCommand *command, char * const *args); int start_action (NihCommand *command, char * const *args); int stop_action (NihCommand *command, char * const *args); int status_action (NihCommand *command, char * const *args); @@ -296,6 +301,8 @@ static UpstartMessage handlers[] = { { -1, UPSTART_VERSION, (UpstartMessageHandler)handle_version }, + { -1, UPSTART_TTY, + (UpstartMessageHandler)handle_tty }, { -1, UPSTART_JOB, (UpstartMessageHandler)handle_job }, { -1, UPSTART_JOB_FINISHED, @@ -687,6 +694,40 @@ handle_version (void *data } /** + * handle_tty: + * @data: data passed to handler, + * @pid: origin of message, + * @type: message type, + * @version: tty device in use. + * + * Handles receipt of the UPSTART_TTY reply from the server, which is + * sent in response to an UPSTART_PUSH_TTY or UPSTART_POP_TTY message. + * + * Output the version string received and mark it as a response. + * + * Returns: zero on success, negative value on error or positive value if the + * command should exit with that exit status. + **/ +static int +handle_tty (void *data, + pid_t pid, + UpstartMessageType type, + const char *tty) +{ + nih_assert (pid > 0); + nih_assert (type == UPSTART_TTY); + nih_assert (tty != NULL); + + if (! event_caused) + num_responses++; + + event_caused = FALSE; + + nih_message ("%s", tty); + + return 0; +} +/** * handle_job: * @data: data passed to handler, * @pid: origin of message, @@ -1802,6 +1843,61 @@ list_action (NihCommand *command, } /** + * pop_tty_action: + * @command: NihCommand invoked, + * @args: command-line arguments. + * + * This function is called for the "pop_tty" command; it takes no arguments. + * + * It reverts the last push_tty command, and replies with the new tty. + * + * Returns: command exit status. + **/ +int +pop_tty_action (NihCommand *command, + char * const *args) +{ + nih_assert (command != NULL); + nih_assert (args != NULL); + + if (initctl_send (UPSTART_POP_TTY) < 0) + return 1; + + return initctl_recv (1); +} + +/** + * push_tty_action: + * @command: NihCommand invoked, + * @args: command-line arguments. + * + * This function is called for the "push_tty" command; it takes a tty device + * name. + * + * It causes upstart to begin using that tty, and replies with the new tty. + * + * Returns: command exit status. + **/ +int +push_tty_action (NihCommand *command, + char * const *args) +{ + nih_assert (command != NULL); + nih_assert (args != NULL); + + if (! args[0]) { + fprintf (stderr, _("%s: missing device name\n"), program_name); + nih_main_suggest_help (); + return 1; + } + + if (initctl_send (UPSTART_PUSH_TTY, args[0]) < 0) + return 1; + + return initctl_recv (1); +} + +/** * emit_action: * @command: NihCommand invoked, * @args: command-line arguments. @@ -2079,6 +2175,24 @@ NihOption version_options[] = { }; /** + * pop_tty_options: + * + * Command-line options accepted for the pop_tty command. + **/ +NihOption pop_tty_options[] = { + NIH_OPTION_LAST +}; + +/** + * push_tty_options: + * + * Command-line options accepted for the push_tty command. + **/ +NihOption push_tty_options[] = { + NIH_OPTION_LAST +}; + +/** * log_priority_options: * * Command-line options accepted for the log-priority command. @@ -2156,6 +2270,16 @@ static NihCommand commands[] = { NULL, &event_commands, events_options, events_action }, + { "push-tty", NULL, + N_("Change the init daemon's tty device"), + NULL, + NULL, push_tty_options, push_tty_action }, + + { "pop-tty", NULL, + N_("Revert the last change to the init daemon's tty device"), + NULL, + NULL, pop_tty_options, pop_tty_action }, + { "version", NULL, N_("Request the version of the init daemon."), NULL,