X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/0ed0735f38c78e11cdf1c2b095ba754a92d2d201..e04c2d50fd96f3f31bc96851c55c6efecc10469c:/client/tripectl.c diff --git a/client/tripectl.c b/client/tripectl.c index ea8aadff..28961252 100644 --- a/client/tripectl.c +++ b/client/tripectl.c @@ -7,7 +7,7 @@ * (c) 2001 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Trivial IP Encryption (TrIPE). * @@ -15,12 +15,12 @@ * 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. @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -60,6 +61,7 @@ #include #include #include +#include #include "util.h" @@ -163,6 +165,7 @@ static void cline(char *p, size_t len, void *b) } else if (strcmp(q, "INFO") == 0) { checkfg(); puts(p); + fflush(stdout); } else if (strcmp(q, "OK") == 0) { checkfg(); exit(0); @@ -176,11 +179,12 @@ static void cline(char *p, size_t len, void *b) } else if (strcmp(q, "BGINFO") == 0) { checkbg(&p); puts(p); + fflush(stdout); } else if (strcmp(q, "BGFAIL") == 0) { 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) @@ -191,6 +195,7 @@ static void sline(char *p, size_t len, void *b) exit(0); } puts(p); + fflush(stdout); } static void uline(char *p, size_t len, void *b) @@ -314,7 +319,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\ @@ -340,6 +345,8 @@ int main(int argc, char *argv[]) if ((p = getenv("TRIPEDIR")) != 0) dir = p; + if ((p = getenv("TRIPESOCK")) != 0) + sock = p; /* --- Parse the arguments --- */ @@ -476,7 +483,7 @@ int main(int argc, char *argv[]) fclose(pidfp); closelog(); if (f & f_daemon) - u_detach(); + detachtty(); execvp(DA(&spawnopts)[0], DA(&spawnopts)); die(127, "couldn't exec `%s': %s", spawnpath, strerror(errno)); } @@ -501,7 +508,7 @@ int main(int argc, char *argv[]) } if (f & f_daemon) { - if (u_daemon()) + if (daemonize()) die(EXIT_FAILURE, "error becoming daemon: %s", strerror(errno)); } if (pidfp) {