+ ipf->readable.delete_tidy= 0; /* we never call oop_rd_delete_{tidy,kill} */
+ ipf->readable.delete_kill= 0;
+
+ ipf->readable_callback= 0;
+ ipf->readable_callback_user= 0;
+
+ ipf->rd= oop_rd_new(loop, &ipf->readable, 0,0);
+ assert(ipf->rd);
+
+ int r= oop_rd_read(ipf->rd, &feedfile_rdstyle, MAX_LINE_FEEDFILE,
+ feedfile_got_article,ipf, feedfile_read_err, ipf);
+ if (r) sysdie("unable start reading feedfile %s",ipf->path);
+}
+
+static void inputfile_reading_stop(InputFile *ipf) {
+ assert(ipf->rd);
+ oop_rd_cancel(ipf->rd);
+ oop_rd_delete(ipf->rd);
+ ipf->rd= 0;
+ assert(!ipf->filemon); /* we shouldn't be monitoring it now */
+}
+
+
+/*========== interaction with innd - state machine ==========*/
+
+/* See official state diagram at top of file. We implement
+ * this as follows:
+ * -8<-
+
+ .=======.
+ ||START||
+ `======='
+ |
+ | open F
+ |
+ | F ENOENT
+ |`---------------------------------------------------.
+ F OPEN OK | |
+ |`---------------- - - - |
+ D ENOENT | D EXISTS see OVERALL STATES diagram |
+ | for full startup logic |
+ ,--------->| |
+ | V |
+ | ============ try to |
+ | NORMAL open D |
+ | [Normal] |
+ | main F tail |
+ | ============ V
+ | | |
+ | | F IS SO BIG WE SHOULD FLUSH, OR TIMEOUT |
+ ^ | hardlink F to D |
+ | [Hardlinked] |
+ | | unlink F |
+ | | our handle onto F is now onto D |
+ | [Moved] |
+ | | |
+ | |<-------------------<---------------------<---------+
+ | | |
+ | | spawn inndcomm flush |
+ | V |
+ | ================== |
+ | FLUSHING[-ABSENT] |
+ | [Flushing] |
+ | main D tail/none |
+ | ================== |
+ | | |
+ | | INNDCOMM FLUSH FAILS ^
+ | |`----------------------->----------. |
+ | | | |
+ | | NO SUCH SITE V |
+ ^ |`--------------->----. ==================== |
+ | | \ FLUSHFAILED[-ABSENT] |
+ | | \ [Moved] |
+ | | FLUSH OK \ main D tail/none |
+ | | open F \ ==================== |
+ | | \ | |
+ | | \ | TIME TO RETRY |
+ | |`------->----. ,---<---'\ `----------------'
+ | | D NONE | | D NONE `----.
+ | V | | V
+ | ============= V V ============
+ | SEPARATED-1 | | DROPPING-1
+ | flsh->rd!=0 | | flsh->rd!=0
+ | [Separated] | | [Dropping]
+ | main F idle | | main none
+ | flsh D tail | | flsh D tail
+ | ============= | | ============
+ | | | | install |
+ ^ | EOF ON D | | defer | EOF ON D
+ | V | | V
+ | =============== | | ===============
+ | SEPARATED-2 | | DROPPING-2
+ | flsh->rd==0 | V flsh->rd==0
+ | [Finishing] | | [Dropping]
+ | main F tail | `. main none
+ | flsh D closed | `. flsh D closed
+ | =============== V `. ===============
+ | | `. |
+ | | ALL D PROCESSED `. | ALL D PROCESSED
+ | V install defer as backlog `. | install defer
+ ^ | close D `. | close D
+ | | unlink D `. | unlink D
+ | | | |
+ | | V V
+ `----------' ==============
+ DROPPED
+ [Dropped]
+ main none
+ flsh none
+ some backlog
+ ==============
+ |
+ | ALL BACKLOG DONE
+ |
+ | unlink lock
+ | exit
+ V
+ ==========
+ (ESRCH)
+ [Droppped]
+ ==========
+ * ->8-
+ */
+
+static void startup_set_input_file(InputFile *f) {
+ assert(!main_input_file);
+ main_input_file= f;
+ inputfile_reading_start(f);
+}
+
+static void statemc_lock(void) {
+ int lockfd;
+ struct stat stab, stabf;
+
+ for (;;) {
+ lockfd= open(path_lock, O_CREAT|O_RDWR, 0600);
+ if (lockfd<0) sysfatal("open lockfile %s", path_lock);
+
+ struct flock fl;
+ memset(&fl,0,sizeof(fl));
+ fl.l_type= F_WRLCK;
+ fl.l_whence= SEEK_SET;
+ int r= fcntl(lockfd, F_SETLK, &fl);
+ if (r==-1) {
+ if (errno==EACCES || isewouldblock(errno)) {
+ if (quiet_multiple) exit(0);
+ fatal("another duct holds the lockfile");
+ }
+ sysfatal("fcntl F_SETLK lockfile %s", path_lock);
+ }
+
+ xfstat_isreg(lockfd, &stabf, path_lock, "lockfile");
+ int lock_noent;
+ xlstat_isreg(path_lock, &stab, &lock_noent, "lockfile");
+
+ if (!lock_noent && samefile(&stab, &stabf))
+ break;
+
+ xclose(lockfd, "stale lockfile ", path_lock);
+ }
+
+ FILE *lockfile= fdopen(lockfd, "w");
+ if (!lockfile) sysdie("fdopen lockfile");
+
+ int r= ftruncate(lockfd, 0);
+ if (r) sysdie("truncate lockfile to write new info");
+
+ if (fprintf(lockfile, "pid %ld\nsite %s\nfeedfile %s\nfqdn %s\n",
+ (unsigned long)self_pid,
+ sitename, feedfile, remote_host) == EOF ||
+ fflush(lockfile))
+ sysfatal("write info to lockfile %s", path_lock);
+
+ debug("startup: locked");
+}
+
+static void statemc_init(void) {
+ struct stat stabdefer;
+
+ search_backlog_file();
+
+ int defer_noent;
+ xlstat_isreg(path_defer, &stabdefer, &defer_noent, "defer file");
+ if (defer_noent) {
+ debug("startup: ductdefer ENOENT");
+ } else {
+ debug("startup: ductdefer nlink=%ld", (long)stabdefer.st_nlink);
+ switch (stabdefer.st_nlink==1) {
+ case 1:
+ open_defer(); /* so that we will later close it and rename it */
+ break;
+ case 2:
+ xunlink(path_defer, "stale defer file link"
+ " (presumably hardlink to backlog file)");
+ break;
+ default:
+ die("defer file %s has unexpected link count %d",
+ path_defer, stabdefer.st_nlink);
+ }
+ }
+
+ struct stat stab_f, stab_d;
+ int noent_f;
+
+ InputFile *file_d= open_input_file(path_flushing);
+ if (file_d) xfstat_isreg(file_d->fd, &stab_d, path_flushing,"flushing file");
+
+ xlstat_isreg(feedfile, &stab_f, &noent_f, "feedfile");
+
+ if (!noent_f && file_d && samefile(&stab_f, &stab_d)) {
+ debug("startup: F==D => Hardlinked");
+ xunlink(feedfile, "feed file (during startup)"); /* => Moved */
+ noent_f= 1;
+ }
+
+ if (noent_f) {
+ debug("startup: F ENOENT => Moved");
+ if (file_d) startup_set_input_file(file_d);
+ spawn_inndcomm_flush("feedfile missing at startup");
+ /* => Flushing, sms:=FLUSHING */
+ } else {
+ if (file_d) {
+ debug("startup: F!=D => Separated");
+ startup_set_input_file(file_d);
+ flushing_input_file= main_input_file;
+ main_input_file= open_input_file(feedfile);
+ if (!main_input_file) die("feedfile vanished during startup");
+ SMS(SEPARATED, 0, "found both old and current feed files");
+ } else {
+ debug("startup: F exists, D ENOENT => Normal");
+ InputFile *file_f= open_input_file(feedfile);
+ if (!file_f) die("feed file vanished during startup");
+ startup_set_input_file(file_f);
+ SMS(NORMAL, spontaneous_flush_periods, "normal startup");
+ }
+ }
+}
+
+static void statemc_start_flush(const char *why) { /* Normal => Flushing */
+ assert(sms == sm_NORMAL);
+
+ debug("starting flush (%s) (%lu >?= %lu) (%d)",
+ why,
+ (unsigned long)(main_input_file ? main_input_file->offset : 0),
+ (unsigned long)target_max_feedfile_size,
+ until_flush);
+
+ int r= link(feedfile, path_flushing);
+ if (r) sysfatal("link feedfile %s to flushing file %s",
+ feedfile, path_flushing);
+ /* => Hardlinked */
+
+ xunlink(feedfile, "old feedfile link");
+ /* => Moved */
+
+ spawn_inndcomm_flush(why); /* => Flushing FLUSHING */
+}
+
+static int trigger_flush_ok(void) { /* => Flushing,FLUSHING, ret 1; or ret 0 */
+ switch (sms) {
+ case sm_NORMAL:
+ statemc_start_flush("periodic"); /* Normal => Flushing; => FLUSHING */
+ return 1;
+ case sm_FLUSHFAILED:
+ spawn_inndcomm_flush("retry"); /* Moved => Flushing; => FLUSHING */
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static void statemc_period_poll(void) {
+ if (!until_flush) return;
+ until_flush--;
+ assert(until_flush>=0);
+
+ if (until_flush) return;
+ int ok= trigger_flush_ok();
+ assert(ok);
+}
+
+static int inputfile_is_done(InputFile *ipf) {
+ if (!ipf) return 0;
+ if (ipf->inprogress) return 0; /* new article in the meantime */
+ if (ipf->rd) return 0; /* not had EOF */
+ return 1;
+}
+
+static void notice_processed(InputFile *ipf, int completed,
+ const char *what, const char *spec) {
+ if (!ipf) return; /* allows preterminate to be lazy */
+
+#define RCI_NOTHING(x) /* nothing */
+#define RCI_TRIPLE_FMT(x) " " #x "=" RCI_TRIPLE_FMT_BASE
+#define RCI_TRIPLE_VALS(x) , RCI_TRIPLE_VALS_BASE(ipf->counts, [RC_##x])
+
+#define CNT(art,rc) (ipf->counts[art_##art][RC_##rc])
+
+ char *inprog= completed
+ ? xasprintf("%s","") /* GCC produces a stupid warning for printf("") ! */
+ : xasprintf(" inprogress=%ld", ipf->inprogress);
+
+ info("%s %s%s read=%d (+bl=%d,+err=%d)%s"
+ " offered=%d (ch=%d,nc=%d) accepted=%d (ch=%d,nc=%d)"
+ RESULT_COUNTS(RCI_NOTHING, RCI_TRIPLE_FMT)
+ ,
+ completed?"completed":"processed", what, spec,
+ ipf->readcount_ok, ipf->readcount_blank, ipf->readcount_err, inprog,
+ CNT(Unchecked,sent) + CNT(Unsolicited,sent)
+ , CNT(Unchecked,sent), CNT(Unsolicited,sent),
+ CNT(Wanted,accepted) + CNT(Unsolicited,accepted)
+ , CNT(Wanted,accepted), CNT(Unsolicited,accepted)
+ RESULT_COUNTS(RCI_NOTHING, RCI_TRIPLE_VALS)
+ );
+
+ free(inprog);
+
+#undef CNT
+}
+
+static void statemc_check_backlog_done(void) {
+ InputFile *ipf= backlog_input_file;
+ if (!inputfile_is_done(ipf)) return;
+
+ const char *slash= strrchr(ipf->path, '/');
+ const char *leaf= slash ? slash+1 : ipf->path;
+ const char *under= strchr(slash, '_');
+ const char *rest= under ? under+1 : leaf;
+ if (!strncmp(rest,"backlog",7)) rest += 7;
+ notice_processed(ipf,1,"backlog ",rest);
+
+ close_input_file(ipf);
+ if (unlink(ipf->path)) {
+ if (errno != ENOENT)
+ sysdie("could not unlink processed backlog file %s", ipf->path);
+ warn("backlog file %s vanished while we were reading it"
+ " so we couldn't remove it (but it's done now, anyway)",
+ ipf->path);
+ }
+ free(ipf);
+ backlog_input_file= 0;
+ search_backlog_file();
+ return;
+}
+
+static void statemc_check_flushing_done(void) {
+ InputFile *ipf= flushing_input_file;
+ if (!inputfile_is_done(ipf)) return;
+
+ assert(sms==sm_SEPARATED || sms==sm_DROPPING);
+
+ notice_processed(ipf,1,"feedfile","");
+
+ close_defer();
+
+ xunlink(path_flushing, "old flushing file");
+
+ close_input_file(flushing_input_file);
+ free(flushing_input_file);
+ flushing_input_file= 0;
+
+ if (sms==sm_SEPARATED) {
+ notice("flush complete");
+ SMS(NORMAL, spontaneous_flush_periods, "flush complete");
+ } else if (sms==sm_DROPPING) {
+ SMS(DROPPED, 0, "old flush complete");
+ search_backlog_file();
+ notice("feed dropped, but will continue until backlog is finished");
+ }
+}
+
+static void *statemc_check_input_done(oop_source *lp, struct timeval now,
+ void *u) {
+ assert(!inputfile_is_done(main_input_file));
+ statemc_check_flushing_done();
+ statemc_check_backlog_done();
+ return OOP_CONTINUE;
+}
+
+static void queue_check_input_done(void) {
+ loop->on_time(loop, OOP_TIME_NOW, statemc_check_input_done, 0);
+}
+
+static void statemc_setstate(StateMachineState newsms, int periods,
+ const char *forlog, const char *why) {
+ sms= newsms;
+ until_flush= periods;
+
+ const char *xtra= "";
+ switch (sms) {
+ case sm_FLUSHING:
+ case sm_FLUSHFAILED:
+ if (!main_input_file) xtra= "-ABSENT";
+ break;
+ case sm_SEPARATED:
+ case sm_DROPPING:
+ xtra= flushing_input_file->rd ? "-1" : "-2";
+ break;
+ default:;
+ }
+
+ if (periods) {
+ info("state %s%s[%d] %s",forlog,xtra,periods,why);
+ } else {
+ info("state %s%s %s",forlog,xtra,why);
+ }
+}
+
+/*---------- defer and backlog files ----------*/
+
+static void open_defer(void) {
+ struct stat stab;
+
+ if (defer) return;
+
+ defer= fopen(path_defer, "a+");
+ if (!defer) sysfatal("could not open defer file %s", path_defer);
+
+ /* truncate away any half-written records */
+
+ xfstat_isreg(fileno(defer), &stab, path_defer, "newly opened defer file");
+
+ if (stab.st_size > LONG_MAX)
+ die("defer file %s size is far too large", path_defer);
+
+ if (!stab.st_size)
+ return;
+
+ long orgsize= stab.st_size;
+ long truncto= stab.st_size;
+ for (;;) {
+ if (!truncto) break; /* was only (if anything) one half-truncated record */
+ if (fseek(defer, truncto-1, SEEK_SET) < 0)
+ sysdie("seek in defer file %s while truncating partial", path_defer);
+
+ int r= getc(defer);
+ if (r==EOF) {
+ if (ferror(defer))
+ sysdie("failed read from defer file %s", path_defer);
+ else
+ die("defer file %s shrank while we were checking it!", path_defer);
+ }
+ if (r=='\n') break;
+ truncto--;
+ }
+
+ if (stab.st_size != truncto) {
+ warn("truncating half-record at end of defer file %s -"
+ " shrinking by %ld bytes from %ld to %ld",
+ path_defer, orgsize - truncto, orgsize, truncto);
+
+ if (fflush(defer))
+ sysfatal("could not flush defer file %s", path_defer);
+ if (ftruncate(fileno(defer), truncto))
+ sysdie("could not truncate defer file %s", path_defer);
+
+ } else {
+ info("continuing existing defer file %s (%ld bytes)",
+ path_defer, orgsize);
+ }
+ if (fseek(defer, truncto, SEEK_SET))
+ sysdie("could not seek to new end of defer file %s", path_defer);
+}
+
+static void close_defer(void) {
+ if (!defer)
+ return;
+
+ struct stat stab;
+ xfstat_isreg(fileno(defer), &stab, path_defer, "defer file");
+
+ if (fclose(defer)) sysfatal("could not close defer file %s", path_defer);
+ defer= 0;
+
+ time_t now= xtime();
+
+ char *backlog= xasprintf("%s_backlog_%lu.%lu", feedfile,
+ (unsigned long)now,
+ (unsigned long)stab.st_ino);
+ if (link(path_defer, backlog))
+ sysfatal("could not install defer file %s as backlog file %s",
+ path_defer, backlog);
+ if (unlink(path_defer))
+ sysdie("could not unlink old defer link %s to backlog file %s",
+ path_defer, backlog);
+
+ free(backlog);
+
+ if (until_backlog_nextscan < 0 ||
+ until_backlog_nextscan > backlog_retry_minperiods + 1)
+ until_backlog_nextscan= backlog_retry_minperiods + 1;
+}
+
+static void poll_backlog_file(void) {
+ if (until_backlog_nextscan < 0) return;
+ if (until_backlog_nextscan-- > 0) return;
+ search_backlog_file();
+}
+
+static void search_backlog_file(void) {
+ /* returns non-0 iff there are any backlog files */
+
+ glob_t gl;
+ int r, i;
+ struct stat stab;
+ const char *oldest_path=0;
+ time_t oldest_mtime=0, now;
+
+ if (backlog_input_file) return;
+
+ try_again:
+
+ r= glob(globpat_backlog, GLOB_ERR|GLOB_MARK|GLOB_NOSORT, 0, &gl);
+
+ switch (r) {
+ case GLOB_ABORTED:
+ sysfatal("failed to expand backlog pattern %s", globpat_backlog);
+ case GLOB_NOSPACE:
+ fatal("out of memory expanding backlog pattern %s", globpat_backlog);
+ case 0:
+ for (i=0; i<gl.gl_pathc; i++) {
+ const char *path= gl.gl_pathv[i];
+
+ if (strchr(path,'#') || strchr(path,'~')) {
+ debug("backlog file search skipping %s", path);
+ continue;
+ }
+ r= stat(path, &stab);
+ if (r) {
+ syswarn("failed to stat backlog file %s", path);
+ continue;
+ }
+ if (!S_ISREG(stab.st_mode)) {
+ warn("backlog file %s is not a plain file (or link to one)", path);
+ continue;
+ }
+ if (!oldest_path || stab.st_mtime < oldest_mtime) {
+ oldest_path= path;
+ oldest_mtime= stab.st_mtime;
+ }
+ }
+ case GLOB_NOMATCH: /* fall through */
+ break;
+ default:
+ sysdie("glob expansion of backlog pattern %s gave unexpected"
+ " nonzero (error?) return value %d", globpat_backlog, r);
+ }
+
+ if (!oldest_path) {
+ debug("backlog scan: none");
+
+ if (sms==sm_DROPPED) {
+ preterminate();
+ notice("feed dropped and our work is complete");
+
+ int r= unlink(path_control);
+ if (r && errno!=ENOENT)
+ syswarn("failed to remove control symlink for old feed");
+
+ xunlink(path_lock, "lockfile for old feed");
+ exit(4);
+ }
+ until_backlog_nextscan= backlog_spontrescan_periods;
+ goto xfree;
+ }
+
+ now= xtime();
+ double age= difftime(now, oldest_mtime);
+ long age_deficiency= (backlog_retry_minperiods * period_seconds) - age;
+
+ if (age_deficiency <= 0) {
+ debug("backlog scan: found age=%f deficiency=%ld oldest=%s",
+ age, age_deficiency, oldest_path);
+
+ backlog_input_file= open_input_file(oldest_path);
+ if (!backlog_input_file) {
+ warn("backlog file %s vanished as we opened it", oldest_path);
+ globfree(&gl);
+ goto try_again;
+ }
+ inputfile_reading_start(backlog_input_file);
+ until_backlog_nextscan= -1;
+ goto xfree;
+ }
+
+ until_backlog_nextscan= age_deficiency / period_seconds;
+
+ if (backlog_spontrescan_periods >= 0 &&
+ until_backlog_nextscan > backlog_spontrescan_periods)
+ until_backlog_nextscan= backlog_spontrescan_periods;
+
+ debug("backlog scan: young age=%f deficiency=%ld nextscan=%d oldest=%s",
+ age, age_deficiency, until_backlog_nextscan, oldest_path);
+
+ xfree:
+ globfree(&gl);
+ return;
+}
+
+/*---------- shutdown and signal handling ----------*/
+
+static void preterminate(void) {
+ if (in_child) return;
+ notice_processed(main_input_file,0,"feedfile","");
+ notice_processed(flushing_input_file,0,"flushing","");
+ if (backlog_input_file)
+ notice_processed(backlog_input_file,0, "backlog file ",
+ backlog_input_file->path);
+}
+
+static int signal_self_pipe[2];
+static sig_atomic_t terminate_sig_flag;
+
+static void raise_default(int signo) {
+ xsigsetdefault(signo);
+ raise(signo);
+ abort();
+}
+
+static void *sigarrived_event(oop_source *lp, int fd, oop_event e, void *u) {
+ assert(fd=signal_self_pipe[0]);
+ char buf[PIPE_BUF];
+ int r= read(signal_self_pipe[0], buf, sizeof(buf));
+ if (r<0 && !isewouldblock(errno)) sysdie("failed to read signal self pipe");
+ if (r==0) die("eof on signal self pipe");
+ if (terminate_sig_flag) {
+ preterminate();
+ notice("terminating (%s)", strsignal(terminate_sig_flag));
+ raise_default(terminate_sig_flag);
+ }
+ return OOP_CONTINUE;
+}
+
+static void sigarrived_handler(int signum) {
+ static char x;
+ switch (signum) {
+ case SIGTERM:
+ case SIGINT:
+ if (!terminate_sig_flag) terminate_sig_flag= signum;
+ break;
+ default:
+ abort();
+ }
+ write(signal_self_pipe[1],&x,1);
+}
+
+static void init_signals(void) {
+ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
+ sysdie("could not ignore SIGPIPE");
+
+ if (pipe(signal_self_pipe)) sysfatal("create self-pipe for signals");
+
+ xsetnonblock(signal_self_pipe[0],1);
+ xsetnonblock(signal_self_pipe[1],1);
+
+ struct sigaction sa;
+ memset(&sa,0,sizeof(sa));
+ sa.sa_handler= sigarrived_handler;
+ sa.sa_flags= SA_RESTART;
+ xsigaction(SIGTERM,&sa);
+ xsigaction(SIGINT,&sa);
+
+ on_fd_read_except(signal_self_pipe[0], sigarrived_event);
+}
+
+/*========== flushing the feed ==========*/
+
+static pid_t inndcomm_child;
+static int inndcomm_sentinel_fd;
+
+static void *inndcomm_event(oop_source *lp, int fd, oop_event e, void *u) {
+ assert(inndcomm_child);
+ assert(fd == inndcomm_sentinel_fd);
+ int status= xwaitpid(&inndcomm_child, "inndcomm");
+ inndcomm_child= 0;
+
+ cancel_fd_read_except(fd);
+ xclose_perhaps(&fd, "inndcomm sentinel pipe",0);
+ inndcomm_sentinel_fd= 0;
+
+ assert(!flushing_input_file);
+
+ if (WIFEXITED(status)) {
+ switch (WEXITSTATUS(status)) {
+
+ case INNDCOMMCHILD_ESTATUS_FAIL:
+ goto failed;
+
+ case INNDCOMMCHILD_ESTATUS_NONESUCH:
+ notice("feed has been dropped by innd, finishing up");
+ flushing_input_file= main_input_file;
+ tailing_queue_readable(flushing_input_file);
+ /* we probably previously returned EAGAIN from our fake read method
+ * when in fact we were at EOF, so signal another readable event
+ * so we actually see the EOF */
+
+ main_input_file= 0;
+
+ if (flushing_input_file) {
+ SMS(DROPPING, 0, "feed dropped by innd, but must finish last flush");
+ } else {
+ close_defer();
+ SMS(DROPPED, 0, "feed dropped by innd");
+ search_backlog_file();
+ }
+ return OOP_CONTINUE;
+
+ case 0:
+ /* as above */
+ flushing_input_file= main_input_file;
+ tailing_queue_readable(flushing_input_file);
+
+ main_input_file= open_input_file(feedfile);
+ if (!main_input_file)
+ die("flush succeeded but feedfile %s does not exist!", feedfile);
+
+ if (flushing_input_file) {
+ SMS(SEPARATED, spontaneous_flush_periods, "recovery flush complete");
+ } else {
+ close_defer();
+ SMS(NORMAL, spontaneous_flush_periods, "flush complete");
+ }
+ return OOP_CONTINUE;
+
+ default:
+ goto unexpected_exitstatus;