=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server.c,v retrieving revision 1.52 retrieving revision 1.53 diff -c -r1.52 -r1.53 *** src/usr.bin/tmux/server.c 2009/10/11 07:01:10 1.52 --- src/usr.bin/tmux/server.c 2009/10/11 07:20:16 1.53 *************** *** 1,4 **** ! /* $OpenBSD: server.c,v 1.52 2009/10/11 07:01:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server.c,v 1.53 2009/10/11 07:20:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 88,93 **** --- 88,94 ---- void server_check_redraw(struct client *); void server_set_title(struct client *); void server_check_timers(struct client *); + void server_check_jobs(void); void server_lock_server(void); void server_lock_sessions(void); void server_check_clients(void); *************** *** 370,376 **** sigusr1 = 0; } ! /* Process client actions. */ server_check_clients(); /* Initialise pollfd array and add server socket. */ --- 371,378 ---- sigusr1 = 0; } ! /* Collect any jobs that have died and process clients. */ ! server_check_jobs(); server_check_clients(); /* Initialise pollfd array and add server socket. */ *************** *** 389,395 **** /* Do the poll. */ pfds = server_poll_flatten(&nfds); - log_debug("polling %d", nfds); if (poll(pfds, nfds, xtimeout) == -1) { if (errno == EAGAIN || errno == EINTR) continue; --- 391,396 ---- *************** *** 510,515 **** --- 511,517 ---- { struct window *w; struct window_pane *wp; + struct job *job; int status; pid_t pid; u_int i; *************** *** 523,530 **** case 0: return; } ! if (!WIFSTOPPED(status)) continue; if (WSTOPSIG(status) == SIGTTIN || WSTOPSIG(status) == SIGTTOU) continue; --- 525,539 ---- case 0: return; } ! if (!WIFSTOPPED(status)) { ! SLIST_FOREACH(job, &all_jobs, lentry) { ! if (pid == job->pid) { ! job->pid = -1; ! job->status = status; ! } ! } continue; + } if (WSTOPSIG(status) == SIGTTIN || WSTOPSIG(status) == SIGTTOU) continue; *************** *** 792,800 **** if (buffer_poll(pfd, job->out, NULL) != 0) { close(job->fd); job->fd = -1; - if (job->callbackfn != NULL) - job->callbackfn(job); } } } --- 801,822 ---- if (buffer_poll(pfd, job->out, NULL) != 0) { close(job->fd); job->fd = -1; } + } + } + + /* Handle job fds. */ + void + server_check_jobs(void) + { + struct job *job; + + SLIST_FOREACH(job, &all_jobs, lentry) { + if (job->flags & JOB_DONE || job->fd != -1 || job->pid != -1) + continue; + if (job->callbackfn != NULL) + job->callbackfn(job); + job->flags |= JOB_DONE; } }