/* -*-c-*-
*
- * $Id: xcatch.c,v 1.1 1998/12/15 23:46:50 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.
+ *
* Revision 1.1 1998/12/15 23:46:50 mdw
* New program: captures input and puts it in a window.
*
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 --- */
"-h, --help Display this help text\n"
"-u, --usage Display a quick usage summary\n"
"-v, --version Display the version number\n"
-"-f, --file=FILE Read input from the named file\n"
-"-F, --font=FONT Display output in the named font\n",
+"-f, --file=FILE\t Read input from the named file\n"
+"-F, --font=FONT\t Display output in the named font\n",
stdout);
exit(0);
break;
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 -------------------------------------------------*/