[PATCH 6/9] add no-daemon command line option
william.jon.mccann at gmail.com
william.jon.mccann at gmail.com
Mon Feb 23 12:35:54 PST 2009
From: William Jon McCann <jmccann at redhat.com>
Useful for debugging and running under gdb
---
src/main.c | 39 +++++++++++++++++++++++++--------------
1 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/src/main.c b/src/main.c
index fe4df58..44ac147 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1144,6 +1144,7 @@ main (int argc,
};
int exit_code;
bool should_help = false;
+ bool no_daemon = false;
ply_daemon_handle_t *daemon_handle;
char *mode_string = NULL;
@@ -1153,6 +1154,7 @@ main (int argc,
ply_command_parser_add_options (state.command_parser,
"help", "This help message", PLY_COMMAND_OPTION_TYPE_FLAG,
+ "no-daemon", "Do not daemonize", PLY_COMMAND_OPTION_TYPE_FLAG,
"mode", "Mode is one of: boot, shutdown", PLY_COMMAND_OPTION_TYPE_STRING,
"attach-to-session", "pty_master_fd", PLY_COMMAND_OPTION_TYPE_LONG,
NULL);
@@ -1172,6 +1174,7 @@ main (int argc,
ply_command_parser_get_options (state.command_parser,
"help", &should_help,
"mode", &mode_string,
+ "no-daemon", &no_daemon,
"attach-to-session", &state.ptmx,
NULL);
if (should_help)
@@ -1208,12 +1211,15 @@ main (int argc,
chdir ("/");
signal (SIGPIPE, SIG_IGN);
- daemon_handle = ply_create_daemon ();
-
- if (daemon_handle == NULL)
+ if (! no_daemon)
{
- ply_error ("cannot daemonize: %m");
- return EX_UNAVAILABLE;
+ daemon_handle = ply_create_daemon ();
+
+ if (daemon_handle == NULL)
+ {
+ ply_error ("cannot daemonize: %m");
+ return EX_UNAVAILABLE;
+ }
}
signal (SIGABRT, on_crash);
@@ -1226,12 +1232,14 @@ main (int argc,
{
if (errno == 0)
{
- ply_detach_daemon (daemon_handle, 0);
+ if (! no_daemon)
+ ply_detach_daemon (daemon_handle, 0);
return 0;
}
ply_error ("could not setup basic operating environment: %m");
- ply_detach_daemon (daemon_handle, EX_OSERR);
+ if (! no_daemon)
+ ply_detach_daemon (daemon_handle, EX_OSERR);
return EX_OSERR;
}
@@ -1242,7 +1250,8 @@ main (int argc,
if (!attach_to_running_session (&state))
{
ply_error ("could not create session: %m");
- ply_detach_daemon (daemon_handle, EX_UNAVAILABLE);
+ if (! no_daemon)
+ ply_detach_daemon (daemon_handle, EX_UNAVAILABLE);
return EX_UNAVAILABLE;
}
}
@@ -1252,15 +1261,17 @@ main (int argc,
if (state.boot_server == NULL)
{
ply_error ("could not log bootup: %m");
- ply_detach_daemon (daemon_handle, EX_UNAVAILABLE);
+ if (! no_daemon)
+ ply_detach_daemon (daemon_handle, EX_UNAVAILABLE);
return EX_UNAVAILABLE;
}
- if (!ply_detach_daemon (daemon_handle, 0))
- {
- ply_error ("could not tell parent to exit: %m");
- return EX_UNAVAILABLE;
- }
+ if (! no_daemon)
+ if (!ply_detach_daemon (daemon_handle, 0))
+ {
+ ply_error ("could not tell parent to exit: %m");
+ return EX_UNAVAILABLE;
+ }
state.progress = ply_progress_new ();
--
1.6.1.3
More information about the plymouth
mailing list