/* -*-c-*-
*
- * $Id: xcatch.c,v 1.2 1998/12/16 00:10:58 mdw Exp $
+ * $Id: xcatch.c,v 1.3 1998/12/20 17:19:16 mdw Exp $
*
* Catch input and trap it in an X window
*
/*----- Revision history --------------------------------------------------*
*
* $Log: xcatch.c,v $
+ * Revision 1.3 1998/12/20 17:19:16 mdw
+ * Return exit status of child process, rather than always returning
+ * success.
+ *
* Revision 1.2 1998/12/16 00:10:58 mdw
* Fix tabbing in help text.
*
f_bogus = 2
};
-GtkWidget *textbox = 0;
-GdkFont *font;
+static GtkWidget *textbox = 0;
+static GdkFont *font;
+
+static pid_t kid = -1;
+static int status;
/*----- Main code ---------------------------------------------------------*/
static void reap(int sig)
{
- while (waitpid(-1, 0, WNOHANG) > 0)
- ;
+ pid_t k;
+ int s;
+
+ for (;;) {
+ k = waitpid(-1, &s, WNOHANG);
+ if (k <= 0)
+ break;
+ if (k == kid) {
+ if (WIFEXITED(s))
+ status = WEXITSTATUS(s);
+ else
+ status = 127;
+ }
+ }
}
/* --- Main program --- */
fd = STDIN_FILENO;
else {
int pfd[2];
- pid_t kid;
struct sigaction sa;
/* --- Set up a signal handler --- */
gdk_input_add(fd, GDK_INPUT_READ, ready, 0);
gtk_main();
- return (0);
+ return (status);
}
/*----- That's all, folks -------------------------------------------------*/