diff -uNr autofs-4.1.4-orig/daemon/automount.c autofs-4.1.4/daemon/automount.c --- autofs-4.1.4-orig/daemon/automount.c 2005-05-10 13:26:53 +0400 +++ autofs-4.1.4/daemon/automount.c 2005-05-10 13:27:37 +0400 @@ -60,6 +60,7 @@ int do_verbose = 0; /* Verbose feedback option */ int do_debug = 0; /* Enable full debug output */ +int daemonize = 1; /* Shall we daemonize? */ sigset_t ready_sigs; /* signals only accepted in ST_READY */ sigset_t lock_sigs; /* signals blocked for locking */ @@ -1282,7 +1283,7 @@ chdir("/"); /* Detach from foreground process */ - if (!submount) { + if (!submount && daemonize) { pid = fork(); if (pid > 0) exit(0); @@ -1310,7 +1311,7 @@ * ouselves from the controling tty. This ensures we don't get unexpected * signals. This call also sets us as the process group leader. */ - if (!submount && (setsid() == -1)) { + if (!submount && daemonize && (setsid() == -1)) { crit("setsid: %s", strerror(errno)); exit(1); } @@ -1381,7 +1382,19 @@ static void usage(void) { - fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program); + fprintf(stderr, + "Usage: %s [options] path map_type [args...]\n" + " -h --help this text\n" + " -p --pid-file f write process id to file f\n" + " -t --timeout n auto-unmount in n seconds (0-disable)\n" + " -f --foreground do not daemonize\n" + " -v --verbose be verbose\n" + " -d --debug be even more verbose\n" + " -V --version print version and exit\n" + /* " -g --ghost \n" */ + /* " --submount \n" */ + , program + ); } static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler) @@ -1668,6 +1681,7 @@ {"help", 0, 0, 'h'}, {"pid-file", 1, 0, 'p'}, {"timeout", 1, 0, 't'}, + {"foreground", 0, 0, 'f'}, {"verbose", 0, 0, 'v'}, {"debug", 0, 0, 'd'}, {"version", 0, 0, 'V'}, @@ -1685,7 +1699,7 @@ ap.dir_created = 0; /* We haven't created the main directory yet */ opterr = 0; - while ((opt = getopt_long(argc, argv, "+hp:t:vdVg", long_options, NULL)) != EOF) { + while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) { switch (opt) { case 'h': usage(); @@ -1699,6 +1713,10 @@ ap.exp_timeout = getnumopt(optarg, opt); break; + case 'f': + daemonize = 0; + break; + case 'v': do_verbose = 1; break; diff -uNr autofs-4.1.4-orig/daemon/automount.c.orig autofs-4.1.4/daemon/automount.c.orig