summaryrefslogtreecommitdiff
path: root/xfconfd
diff options
context:
space:
mode:
authorBrian J. Tarricone <brian@tarricone.org>2009-09-18 15:48:19 -0700
committerBrian J. Tarricone <brian@tarricone.org>2009-09-18 15:48:19 -0700
commit2841ba12edb0281757d456ea398d4750e28a7467 (patch)
tree0d98f8cc0581d303e22d6a3aeafc303682dcb6b2 /xfconfd
parent65d1fe5e7ec68bc69aab890a074a89bc73b80444 (diff)
downloadxfconf-2841ba12edb0281757d456ea398d4750e28a7467.tar.gz
fix test framework, hopefully for the last time
add a --daemon option to xfconfd that forks(), prints its new child pid, and quits. this lets us move xfconfd launching into the test script and out of the C file. also we make sure to kill xfconfd and dbus-daemon after each test run. this seems to work without any weird dbus errors.
Diffstat (limited to 'xfconfd')
-rw-r--r--xfconfd/main.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/xfconfd/main.c b/xfconfd/main.c
index 7ca223e..cbdc269 100644
--- a/xfconfd/main.c
+++ b/xfconfd/main.c
@@ -127,12 +127,16 @@ main(int argc,
GOptionContext *opt_ctx;
gchar **backends = NULL;
gboolean print_version = FALSE;
+ gboolean do_daemon = FALSE;
GOptionEntry options[] = {
- { "version", 'V', 0, G_OPTION_ARG_NONE, &print_version,
+ { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &print_version,
N_("Prints the xfconfd version."), NULL },
- { "backends", 'b', 0, G_OPTION_ARG_STRING_ARRAY, &backends,
+ { "backends", 'b', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING_ARRAY, &backends,
N_("Configuration backends to use. The first backend specified " \
"is opened read/write; the others, read-only."), NULL },
+ { "daemon", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &do_daemon,
+ N_("Fork into background after starting; only useful for " \
+ "testing purposes"), NULL },
{ NULL, 0, 0, 0, 0, NULL, NULL },
};
@@ -208,6 +212,21 @@ main(int argc,
return EXIT_FAILURE;
}
g_strfreev(backends);
+
+ if(do_daemon) {
+ pid_t child_pid;
+
+ child_pid = fork();
+ if(child_pid < 0) {
+ g_printerr("Failed to fork()\n");
+ return 1;
+ } else if(child_pid > 0) {
+ fprintf(stdout, "XFCONFD_PID=%d; export XFCONFD_PID;", child_pid);
+ exit(0);
+ }
+
+ close(fileno(stdout));
+ }
g_main_loop_run(mloop);