[gdm] Use standard exit codes.
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] Use standard exit codes.
- Date: Tue, 3 Oct 2017 20:18:42 +0000 (UTC)
commit 69420ae2c587c75cfb915330d4f60f866281345b
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Sep 28 15:33:50 2017 -0400
Use standard exit codes.
Use EXIT_ defines for readibility.
There were some exit codes > 1, but they don't seem to be checked by any of the
parent process code. This does mean that the logs might have changed, but
modern logging techniques have probably made this obsolete.
https://bugzilla.gnome.org/show_bug.cgi?id=788307
chooser/chooser-main.c | 4 ++--
daemon/gdm-display.c | 2 +-
daemon/gdm-local-display-factory.c | 4 ++--
daemon/gdm-manager.c | 4 ++--
daemon/gdm-server.c | 22 +++++++---------------
daemon/gdm-session-worker.c | 14 +++++++-------
daemon/gdm-session.c | 2 +-
daemon/main.c | 12 ++++++------
daemon/session-worker-main.c | 8 ++++----
daemon/test-session-client.c | 14 +++++++-------
tests/m-common.c | 2 +-
utils/gdm-screenshot.c | 6 +++---
utils/gdmflexiserver.c | 2 +-
13 files changed, 44 insertions(+), 52 deletions(-)
---
diff --git a/chooser/chooser-main.c b/chooser/chooser-main.c
index 54aebf1..6f94c62 100644
--- a/chooser/chooser-main.c
+++ b/chooser/chooser-main.c
@@ -229,7 +229,7 @@ main (int argc, char *argv[])
session = gdm_chooser_session_new ();
if (session == NULL) {
g_critical ("Unable to create chooser session");
- exit (1);
+ exit (EXIT_FAILURE);
}
error = NULL;
@@ -237,7 +237,7 @@ main (int argc, char *argv[])
if (! res) {
g_warning ("Unable to start chooser session: %s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
gtk_main ();
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 2d7eacf..1f1ecb6 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -1103,7 +1103,7 @@ register_display (GdmDisplay *self)
if (self->priv->connection == NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
self->priv->object_skeleton = g_dbus_object_skeleton_new (self->priv->id);
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 95bdc59..b29f5ac 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -678,7 +678,7 @@ register_factory (GdmLocalDisplayFactory *factory)
if (factory->priv->connection == NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
factory->priv->skeleton = GDM_DBUS_LOCAL_DISPLAY_FACTORY
(gdm_dbus_local_display_factory_skeleton_new ());
@@ -694,7 +694,7 @@ register_factory (GdmLocalDisplayFactory *factory)
&error)) {
g_critical ("error exporting LocalDisplayFactory object: %s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
return TRUE;
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index e9f8465..256b644 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -2530,7 +2530,7 @@ register_manager (GdmManager *manager)
if (manager->priv->connection == NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
object_server = g_dbus_object_manager_server_new (GDM_MANAGER_DISPLAYS_PATH);
@@ -2545,7 +2545,7 @@ register_manager (GdmManager *manager)
GDM_MANAGER_PATH,
error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
return TRUE;
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index 79cddc6..83fba99 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -65,14 +65,6 @@ extern char **environ;
#define GDM_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SERVER, GdmServerPrivate))
-/* These are the servstat values, also used as server
- * process exit codes */
-#define SERVER_TIMEOUT 2 /* Server didn't start */
-#define SERVER_DEAD 250 /* Server stopped */
-#define SERVER_PENDING 251 /* Server started but not ready for connections yet */
-#define SERVER_RUNNING 252 /* Server running and ready for connections */
-#define SERVER_ABORT 253 /* Server failed badly. Suspending display. */
-
#define MAX_LOGS 5
struct GdmServerPrivate
@@ -390,7 +382,7 @@ change_user (GdmServer *server)
if (pwent == NULL) {
g_warning (_("Server was to be spawned by user %s but that user doesn’t exist"),
server->priv->user_name);
- _exit (1);
+ _exit (EXIT_FAILURE);
}
g_debug ("GdmServer: Changing (uid:gid) for child process to (%d:%d)",
@@ -401,19 +393,19 @@ change_user (GdmServer *server)
if (setgid (pwent->pw_gid) < 0) {
g_warning (_("Couldn’t set groupid to %d"),
pwent->pw_gid);
- _exit (1);
+ _exit (EXIT_FAILURE);
}
if (initgroups (pwent->pw_name, pwent->pw_gid) < 0) {
g_warning (_("initgroups () failed for %s"),
pwent->pw_name);
- _exit (1);
+ _exit (EXIT_FAILURE);
}
if (setuid (pwent->pw_uid) < 0) {
g_warning (_("Couldn’t set userid to %d"),
(int)pwent->pw_uid);
- _exit (1);
+ _exit (EXIT_FAILURE);
}
} else {
gid_t groups[1] = { 0 };
@@ -512,19 +504,19 @@ server_child_setup (GdmServer *server)
if (sigaction (SIGUSR1, &ign_signal, NULL) < 0) {
g_warning (_("%s: Error setting %s to %s"),
"gdm_server_spawn", "USR1", "SIG_IGN");
- _exit (SERVER_ABORT);
+ _exit (EXIT_FAILURE);
}
if (sigaction (SIGTTIN, &ign_signal, NULL) < 0) {
g_warning (_("%s: Error setting %s to %s"),
"gdm_server_spawn", "TTIN", "SIG_IGN");
- _exit (SERVER_ABORT);
+ _exit (EXIT_FAILURE);
}
if (sigaction (SIGTTOU, &ign_signal, NULL) < 0) {
g_warning (_("%s: Error setting %s to %s"),
"gdm_server_spawn", "TTOU", "SIG_IGN");
- _exit (SERVER_ABORT);
+ _exit (EXIT_FAILURE);
}
/* And HUP and TERM are at SIG_DFL from gdm_unset_signals,
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 543006b..9ef4c5b 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -1920,7 +1920,7 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
if (setsid () < 0) {
g_debug ("GdmSessionWorker: could not set pid '%u' as leader of new session and
process group: %s",
(guint) getpid (), g_strerror (errno));
- _exit (2);
+ _exit (EXIT_FAILURE);
}
/* Take control of the tty
@@ -1935,12 +1935,12 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
if (setusercontext (NULL, passwd_entry, passwd_entry->pw_uid, LOGIN_SETALL) < 0) {
g_debug ("GdmSessionWorker: setusercontext() failed for user %s: %s",
passwd_entry->pw_name, g_strerror (errno));
- _exit (1);
+ _exit (EXIT_FAILURE);
}
#else
if (setuid (worker->priv->uid) < 0) {
g_debug ("GdmSessionWorker: could not reset uid: %s", g_strerror (errno));
- _exit (1);
+ _exit (EXIT_FAILURE);
}
#endif
@@ -2040,7 +2040,7 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
worker->priv->arguments[0],
g_strerror (errno));
- _exit (127);
+ _exit (EXIT_FAILURE);
}
if (worker->priv->session_tty_fd > 0) {
@@ -3150,7 +3150,7 @@ gdm_session_worker_constructor (GType type,
g_warning ("error opening connection: %s", error->message);
g_clear_error (&error);
- exit (1);
+ exit (EXIT_FAILURE);
}
worker->priv->manager = GDM_DBUS_WORKER_MANAGER (gdm_dbus_worker_manager_proxy_new_sync
(worker->priv->connection,
@@ -3163,7 +3163,7 @@ gdm_session_worker_constructor (GType type,
g_warning ("error creating session proxy: %s", error->message);
g_clear_error (&error);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (worker),
@@ -3171,7 +3171,7 @@ gdm_session_worker_constructor (GType type,
GDM_WORKER_DBUS_PATH,
&error)) {
g_warning ("Error while exporting object: %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (worker->priv->manager), G_MAXINT);
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index 1f1f6ee..af9f6fb 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -2434,7 +2434,7 @@ get_session_command (GdmSession *self)
res = get_session_command_for_name (self, session_name, &command);
if (! res) {
g_critical ("Cannot find a command for specified session: %s", session_name);
- exit (1);
+ exit (EXIT_FAILURE);
}
return command;
diff --git a/daemon/main.c b/daemon/main.c
index cf8600d..4a5c549 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -337,19 +337,19 @@ main (int argc,
if (! res) {
g_printerr ("Failed to parse options: %s\n", error->message);
g_error_free (error);
- return 1;
+ return EXIT_FAILURE;
}
if (print_version) {
g_print ("GDM %s\n", VERSION);
- return 1;
+ return EXIT_SUCCESS;
}
/* XDM compliant error message */
if (getuid () != 0) {
/* make sure the pid file doesn't get wiped */
g_printerr ("%s\n", _("Only the root user can run GDM"));
- return -1;
+ return EXIT_FAILURE;
}
if (fatal_warnings) {
@@ -365,7 +365,7 @@ main (int argc,
settings = gdm_settings_new ();
if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
g_warning ("Unable to initialize settings");
- return 1;
+ return EXIT_FAILURE;
}
gdm_log_set_debug (is_debug_set ());
@@ -405,7 +405,7 @@ main (int argc,
g_main_loop_unref (main_loop);
- return 0;
+ return EXIT_SUCCESS;
}
static void
@@ -419,7 +419,7 @@ on_name_acquired (GDBusConnection *bus,
manager = gdm_manager_new ();
if (manager == NULL) {
g_warning ("Could not construct manager object");
- exit (1);
+ exit (EXIT_FAILURE);
}
g_debug ("Successfully connected to D-Bus");
diff --git a/daemon/session-worker-main.c b/daemon/session-worker-main.c
index 051d7f9..4a3a8eb 100644
--- a/daemon/session-worker-main.c
+++ b/daemon/session-worker-main.c
@@ -67,7 +67,7 @@ is_debug_set (void)
static void
on_sigterm_cb (int signal_number)
{
- _exit (0);
+ _exit (EXIT_SUCCESS);
}
int
@@ -102,12 +102,12 @@ main (int argc,
settings = gdm_settings_new ();
if (settings == NULL) {
g_warning ("Unable to initialize settings");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
g_warning ("Unable to initialize settings");
- exit (1);
+ exit (EXIT_FAILURE);
}
gdm_log_set_debug (is_debug_set ());
@@ -115,7 +115,7 @@ main (int argc,
address = g_getenv ("GDM_SESSION_DBUS_ADDRESS");
if (address == NULL) {
g_warning ("GDM_SESSION_DBUS_ADDRESS not set");
- exit (1);
+ exit (EXIT_FAILURE);
}
is_for_reauth = g_getenv ("GDM_SESSION_FOR_REAUTH") != NULL;
diff --git a/daemon/test-session-client.c b/daemon/test-session-client.c
index a38cbfd..ae4f59d 100644
--- a/daemon/test-session-client.c
+++ b/daemon/test-session-client.c
@@ -125,7 +125,7 @@ on_secret_info_query (GdmDBusUserVerifier *user_verifier,
if (tcsetattr (fileno (stdin), TCSAFLUSH, &ts1) != 0) {
fprintf (stderr, "Could not set terminal attributes\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
answer[0] = '\0';
@@ -164,7 +164,7 @@ main (int argc,
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (system_bus == NULL) {
g_critical ("Failed connecting to the system bus (this is pretty bad): %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
manager = GDM_DBUS_MANAGER (gdm_dbus_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
@@ -175,7 +175,7 @@ main (int argc,
&error));
if (manager == NULL) {
g_critical ("Failed creating display proxy: %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
address = NULL;
@@ -186,7 +186,7 @@ main (int argc,
&error);
if (address == NULL) {
g_critical ("Failed opening reauthentication channel: %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
connection = g_dbus_connection_new_for_address_sync (address,
@@ -196,7 +196,7 @@ main (int argc,
&error);
if (connection == NULL) {
g_critical ("Failed connecting to the manager: %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
user_verifier = GDM_DBUS_USER_VERIFIER (gdm_dbus_user_verifier_proxy_new_sync (connection,
@@ -207,7 +207,7 @@ main (int argc,
&error));
if (user_verifier == NULL) {
g_critical ("Failed creating user verifier proxy: %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
g_signal_connect (user_verifier,
@@ -246,7 +246,7 @@ main (int argc,
&error);
if (!ok) {
g_critical ("Failed to start PAM session: %s", error->message);
- exit (1);
+ exit (EXIT_FAILURE);
}
diff --git a/tests/m-common.c b/tests/m-common.c
index 62f1f44..0c533d0 100644
--- a/tests/m-common.c
+++ b/tests/m-common.c
@@ -54,7 +54,7 @@ main (int argc, char **argv)
if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
r = srunner_create (suite_common_address ());
diff --git a/utils/gdm-screenshot.c b/utils/gdm-screenshot.c
index c891982..7d1e2cf 100644
--- a/utils/gdm-screenshot.c
+++ b/utils/gdm-screenshot.c
@@ -239,7 +239,7 @@ prepare_screenshot (void)
char *filename;
if (!screenshot_grab_lock ()) {
- exit (0);
+ exit (EXIT_SUCCESS);
}
win = GDK_ROOT_WINDOW ();
@@ -250,7 +250,7 @@ prepare_screenshot (void)
if (screenshot == NULL) {
/* FIXME: dialog? */
- exit (1);
+ exit (EXIT_FAILURE);
}
play_sound_effect (win);
@@ -287,7 +287,7 @@ main (int argc, char *argv[])
if (! res) {
g_warning ("%s", error->message);
g_error_free (error);
- exit (1);
+ exit (EXIT_FAILURE);
}
prepare_screenshot ();
diff --git a/utils/gdmflexiserver.c b/utils/gdmflexiserver.c
index 02ffdb3..68b8ac9 100644
--- a/utils/gdmflexiserver.c
+++ b/utils/gdmflexiserver.c
@@ -143,7 +143,7 @@ main (int argc, char *argv[])
if (show_version) {
g_print ("%s %s\n", argv [0], VERSION);
- exit (1);
+ exit (EXIT_FAILURE);
}
/* don't support commands other than VERSION */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]