~mdw
/
xtoys
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Miscellaneous changes, mostly concerning options parsing.
[xtoys]
/
xcatch.c
diff --git
a/xcatch.c
b/xcatch.c
index
9a6c636
..
4f99d19
100644
(file)
--- a/
xcatch.c
+++ b/
xcatch.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: xcatch.c,v 1.
6 1999/05/19 20:41:1
5 mdw Exp $
+ * $Id: xcatch.c,v 1.
8 1999/06/19 23:42:5
5 mdw Exp $
*
* Catch input and trap it in an X window
*
*
* Catch input and trap it in an X window
*
@@
-29,6
+29,12
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: xcatch.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: xcatch.c,v $
+ * Revision 1.8 1999/06/19 23:42:55 mdw
+ * Improve signal handling. Fix options parsing to POSIX order only.
+ *
+ * Revision 1.7 1999/05/21 22:09:19 mdw
+ * Take advantage of new dynamic string macros.
+ *
* Revision 1.6 1999/05/19 20:41:15 mdw
* Track gratuitous change in mdwopt interface.
*
* Revision 1.6 1999/05/19 20:41:15 mdw
* Track gratuitous change in mdwopt interface.
*
@@
-231,6
+237,7
@@
static void reap(int sig)
{
pid_t k;
int s;
{
pid_t k;
int s;
+ int e = errno;
for (;;) {
k = waitpid(-1, &s, WNOHANG);
for (;;) {
k = waitpid(-1, &s, WNOHANG);
@@
-243,6
+250,7
@@
static void reap(int sig)
status = 127;
}
}
status = 127;
}
}
+ errno = e;
}
/* --- Main program --- */
}
/* --- Main program --- */
@@
-274,7
+282,7
@@
int main(int argc, char *argv[])
{ "font", OPTF_ARGREQ, 0, 'F' },
{ 0, 0, 0, 0 }
};
{ "font", OPTF_ARGREQ, 0, 'F' },
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "huvf:F:", opt, 0, 0, 0);
+ int i = mdwopt(argc, argv, "
+
huvf:F:", opt, 0, 0, 0);
if (i < 0)
break;
if (i < 0)
break;
@@
-339,7
+347,10
@@
int main(int argc, char *argv[])
sa.sa_handler = reap;
sigemptyset(&sa.sa_mask);
sa.sa_handler = reap;
sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
+ sa.sa_flags = SA_NOCLDSTOP;
+#ifdef SA_RESTART
+ sa.sa_flags |= SA_RESTART;
+#endif
sigaction(SIGCHLD, &sa, 0);
/* --- Start a child program --- */
sigaction(SIGCHLD, &sa, 0);
/* --- Start a child program --- */
@@
-355,7
+366,7
@@
int main(int argc, char *argv[])
if (kid < 0)
die(1, "couldn't fork: %s", strerror(errno));
if (kid == 0) {
if (kid < 0)
die(1, "couldn't fork: %s", strerror(errno));
if (kid == 0) {
- dstr d;
+ dstr d
= DSTR_INIT
;
close(pfd[0]);
if (pfd[1] != STDOUT_FILENO)
close(pfd[0]);
if (pfd[1] != STDOUT_FILENO)
@@
-366,10
+377,10
@@
int main(int argc, char *argv[])
close(pfd[1]);
execvp(argv[optind], argv + optind);
close(pfd[1]);
execvp(argv[optind], argv + optind);
- dstr_create(&d);
dstr_putf(&d, "%s: couldn't run `%s': %s\n",
QUIS, argv[optind], strerror(errno));
write(STDERR_FILENO, d.buf, d.len);
dstr_putf(&d, "%s: couldn't run `%s': %s\n",
QUIS, argv[optind], strerror(errno));
write(STDERR_FILENO, d.buf, d.len);
+ dstr_destroy(&d);
_exit(127);
}
_exit(127);
}