Mercurial > hg > mlmmj
changeset 64:4a8c5a8cebbc
added -F (no fork) option
author | mortenp |
---|---|
date | Fri, 30 Apr 2004 17:20:01 +1000 |
parents | 555fe1fd42b8 |
children | ce8b0e73888e |
files | src/mlmmj-recieve.c |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mlmmj-recieve.c Wed Apr 28 22:12:16 2004 +1000 +++ b/src/mlmmj-recieve.c Fri Apr 30 17:20:01 2004 +1000 @@ -26,7 +26,7 @@ static void print_help(const char *prg) { - printf("Usage: %s -L /path/to/chat-list [-V] [-P]\n", prg); + printf("Usage: %s -L /path/to/chat-list [-V] [-P] [-F]\n", prg); exit(EXIT_SUCCESS); } @@ -35,7 +35,7 @@ char *infilename = NULL, *listdir = NULL, *line = NULL; char *randomstr = random_str(); char *mlmmjprocess, *argv0 = strdup(argv[0]); - int fd, opt, noprocess = 0; + int fd, opt, noprocess = 0, nofork = 0; pid_t childpid; log_set_name(argv[0]); @@ -43,7 +43,7 @@ mlmmjprocess = concatstr(2, dirname(argv0), "/mlmmj-process"); free(argv0); - while ((opt = getopt(argc, argv, "hPVL:")) != -1) { + while ((opt = getopt(argc, argv, "hPVL:F")) != -1) { switch(opt) { case 'h': print_help(argv[0]); @@ -54,6 +54,9 @@ case 'P': noprocess = 1; break; + case 'F': + nofork = 1; + break; case 'V': print_version(argv[0]); exit(0); @@ -105,12 +108,14 @@ * returning, making it susceptible to getting a SIGKILL from the * mailserver invoking mlmmj-recieve. */ + if (!nofork) { childpid = fork(); if(childpid < 0) log_error(LOG_ARGS, "fork() failed! Proceeding anyway"); if(childpid) exit(EXIT_SUCCESS); /* Parent says: "bye bye kids!"*/ + } execlp(mlmmjprocess, mlmmjprocess, "-L", listdir,