summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2014-09-06 16:24:33 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2014-09-06 16:24:33 +0000
commit38474ba9ae4415cb2a27f51fc6f2ed69fcc57820 (patch)
tree872a33fa3c6ae1a7ea33c6c0ea502395ccf33643 /app/cwm
parent4baf0c9a909adcc9299909f8360d71e2758ca4cc (diff)
generic sighandler
Diffstat (limited to 'app/cwm')
-rw-r--r--app/cwm/calmwm.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c
index cfee9ee45..cb84154cb 100644
--- a/app/cwm/calmwm.c
+++ b/app/cwm/calmwm.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.c,v 1.89 2014/02/02 16:29:04 okan Exp $
+ * $OpenBSD: calmwm.c,v 1.90 2014/09/06 16:24:32 okan Exp $
*/
#include <sys/param.h>
@@ -48,7 +48,7 @@ struct conf Conf;
const char *homedir;
volatile sig_atomic_t cwm_status;
-static void sigchld_cb(int);
+static void sighdlr(int);
static int x_errorhandler(Display *, XErrorEvent *);
static void x_init(const char *);
static void x_restart(char **);
@@ -84,7 +84,7 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (signal(SIGCHLD, sigchld_cb) == SIG_ERR)
+ if (signal(SIGCHLD, sighdlr) == SIG_ERR)
err(1, "signal");
if ((homedir = getenv("HOME")) == NULL || *homedir == '\0') {
@@ -205,16 +205,19 @@ x_errorhandler(Display *dpy, XErrorEvent *e)
}
static void
-sigchld_cb(int which)
+sighdlr(int sig)
{
pid_t pid;
- int save_errno = errno;
- int status;
-
- /* Collect dead children. */
- while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
- (pid < 0 && errno == EINTR))
- ;
+ int save_errno = errno, status;
+
+ switch (sig) {
+ case SIGCHLD:
+ /* Collect dead children. */
+ while ((pid = waitpid(WAIT_ANY, &status, WNOHANG)) > 0 ||
+ (pid < 0 && errno == EINTR))
+ ;
+ break;
+ }
errno = save_errno;
}