From 3f171917f6bce0fd5eb808a11b80d550d2a7d249 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 23 Jan 2009 16:19:56 +0000 Subject: [PATCH] Return 1 on error. Doh. --- CHANGES | 6 +++++- tmux.c | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 3fb14b6f..0d06ff20 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +23 January 2009 + +* Oops. Return non-zero on error. Reported by Will Maier. + 21 January 2009 * Handle SIGTERM (and kill-server which uses it), a bit more neatly - tidy @@ -997,7 +1001,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.230 2009-01-21 22:47:31 nicm Exp $ +$Id: CHANGES,v 1.231 2009-01-23 16:19:56 nicm Exp $ LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms diff --git a/tmux.c b/tmux.c index 515029ce..31bd68cb 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.101 2009-01-21 22:47:31 nicm Exp $ */ +/* $Id: tmux.c,v 1.102 2009-01-23 16:19:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -187,7 +187,7 @@ main(int argc, char **argv) struct passwd *pw; char *path, *cause, *home, *pass = NULL; char rpath[MAXPATHLEN], cwd[MAXPATHLEN]; - int n, opt, flags, unlock, start_server; + int retcode, opt, flags, unlock, start_server; unlock = flags = 0; path = NULL; @@ -377,6 +377,7 @@ main(int argc, char **argv) } buffer_destroy(b); + retcode = 0; for (;;) { pfd.fd = cctx.srv_fd; pfd.events = POLLIN; @@ -403,9 +404,10 @@ main(int argc, char **argv) switch (hdr.type) { case MSG_EXIT: case MSG_SHUTDOWN: - n = 0; goto out; case MSG_ERROR: + retcode = 1; + /* FALLTHROUGH */ case MSG_PRINT: if (hdr.size > INT_MAX - 1) fatalx("bad MSG_PRINT size"); @@ -415,7 +417,7 @@ main(int argc, char **argv) buffer_remove(cctx.srv_in, hdr.size); goto restart; case MSG_READY: - n = client_main(&cctx); + retcode = client_main(&cctx); goto out; default: fatalx("unexpected command"); @@ -433,5 +435,5 @@ out: #ifdef DEBUG xmalloc_report(getpid(), "client"); #endif - return (n); + return (retcode); }