chiark
/
gitweb
/
~mdw
/
xtoys
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
de04728
)
Return exit status of child process, rather than always returning
1.2.2
author
mdw
<mdw>
Sun, 20 Dec 1998 17:19:16 +0000
(17:19 +0000)
committer
mdw
<mdw>
Sun, 20 Dec 1998 17:19:16 +0000
(17:19 +0000)
success.
xcatch.c
patch
|
blob
|
blame
|
history
diff --git
a/xcatch.c
b/xcatch.c
index a56112ebaeb268cb18bb9ce07e1189c148c07a9a..9a69aa1f81277a07e970ceffad7845e523007c48 100644
(file)
--- a/
xcatch.c
+++ b/
xcatch.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-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
*
*
* Catch input and trap it in an X window
*
@@
-29,6
+29,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: xcatch.c,v $
/*----- 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.2 1998/12/16 00:10:58 mdw
* Fix tabbing in help text.
*
@@
-70,8
+74,11
@@
enum {
f_bogus = 2
};
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 ---------------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
@@
-172,8
+179,20
@@
static void ready(gpointer data, gint fd, GdkInputCondition c)
static void reap(int sig)
{
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 --- */
}
/* --- Main program --- */
@@
-263,7
+282,6
@@
int main(int argc, char *argv[])
fd = STDIN_FILENO;
else {
int pfd[2];
fd = STDIN_FILENO;
else {
int pfd[2];
- pid_t kid;
struct sigaction sa;
/* --- Set up a signal handler --- */
struct sigaction sa;
/* --- Set up a signal handler --- */
@@
-305,7
+323,7
@@
int main(int argc, char *argv[])
gdk_input_add(fd, GDK_INPUT_READ, ready, 0);
gtk_main();
gdk_input_add(fd, GDK_INPUT_READ, ready, 0);
gtk_main();
- return (
0
);
+ return (
status
);
}
/*----- That's all, folks -------------------------------------------------*/
}
/*----- That's all, folks -------------------------------------------------*/