chiark / gitweb /
server: Option `-F' to run the server in the `foreground'.
[tripe] / client / tripectl.c
index b27d3fdcbf331da023c15009b7ebabf35ff0786d..e171b0da8661b79f83a461875cd573f9f9909e56 100644 (file)
@@ -1,13 +1,11 @@
 /* -*-c-*-
- *
- * $Id$
  *
  * Client for TrIPE
  *
  * (c) 2001 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Trivial IP Encryption (TrIPE).
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * TrIPE is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with TrIPE; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -122,10 +120,7 @@ static void checkbg(char **p)
 }
 
 static void checkfg(void)
-{
-  if (bgtag)
-    die(EXIT_FAILURE, "unexpected foreground response");
-}
+  { if (bgtag) die(EXIT_FAILURE, "unexpected foreground response"); }
 
 static void cline(char *p, size_t len, void *b)
 {
@@ -184,7 +179,7 @@ static void cline(char *p, size_t len, void *b)
     checkbg(&p);
     die(EXIT_FAILURE, "%s", p);
   } else
-    die(EXIT_FAILURE, "unexpected output `%s %s'", q, p); 
+    die(EXIT_FAILURE, "unexpected output `%s %s'", q, p);
 }
 
 static void sline(char *p, size_t len, void *b)
@@ -275,18 +270,10 @@ static void logfile(const char *name)
 
 static void sighup(int sig, void *v) { logfile(logname); }
 
-static void cleanup(void)
-{
-  if (pidfile)
-    unlink(pidfile);
-}
+static void cleanup(void) { if (pidfile) unlink(pidfile); }
 
 static void sigdie(int sig)
-{
-  cleanup();
-  signal(sig, SIG_DFL);
-  raise(sig);
-}
+  { cleanup(); signal(sig, SIG_DFL); raise(sig); }
 
 static void version(FILE *fp)
   { pquis(fp, "$, TrIPE version " VERSION "\n"); }
@@ -319,7 +306,7 @@ Options in full:\n\
 -D, --daemon           Become a background task after connecting.\n\
 -d, --directory=DIR    Select current directory [default " CONFIGDIR "].\n\
 -a, --admin-socket=FILE        Select socket to connect to\n\
-                          [default " SOCKETDIR "/tripesock].\n\
+                         [default " SOCKETDIR "/tripesock].\n\
 -P, --pidfile=FILE     Write process-id to FILE.\n\
 \n\
 -s, --spawn            Start server rather than connecting.\n\
@@ -463,6 +450,7 @@ int main(int argc, char *argv[])
     DA_UNSHIFT(&spawnopts, (char *)sock);
     DA_UNSHIFT(&spawnopts, "-a");
     DA_UNSHIFT(&spawnopts, "-d.");
+    DA_UNSHIFT(&spawnopts, "-F");
     DA_UNSHIFT(&spawnopts, (char *)spawnpath);
     DA_PUSH(&spawnopts, 0);
     if (socketpair(PF_UNIX, SOCK_STREAM, 0, pfd))
@@ -475,15 +463,12 @@ int main(int argc, char *argv[])
     if (!kid) {
       dup2(pfd[1], STDIN_FILENO);
       dup2(pfd[1], STDOUT_FILENO);
-      close(pfd[1]);
       close(pfd[0]);
-      if (logfp)
-       fclose(logfp);
-      if (pidfp)
-       fclose(pidfp);
+      close(pfd[1]);
+      if (logfp) fclose(logfp);
+      if (pidfp) fclose(pidfp);
       closelog();
-      if (f & f_daemon)
-       detachtty();
+      if (f & f_daemon) detachtty();
       execvp(DA(&spawnopts)[0], DA(&spawnopts));
       die(127, "couldn't exec `%s': %s", spawnpath, strerror(errno));
     }