From d39201e64e1be312882973e3ef87872dd44837f5 Mon Sep 17 00:00:00 2001 From: jperkin Date: Mon, 14 Jan 2013 14:33:28 +0000 Subject: pbulk-base-0.47: Portability fixes - Prefer fcntl FD_CLOEXEC to ioctl FIOCLEX. - Reset SIGPIPE action to default for the build child, avoids 'yes' spinning indefinitely on EPIPE in Solaris builds, notably for print/pdf2djvu. --- pkgtools/pbulk/files/pbulk/pbuild/master.c | 10 +++------- pkgtools/pbulk/files/pbulk/pbuild/pbuild.c | 12 +++++++++++- pkgtools/pbulk/files/pbulk/pscan/master.c | 10 +++------- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'pkgtools/pbulk') diff --git a/pkgtools/pbulk/files/pbulk/pbuild/master.c b/pkgtools/pbulk/files/pbulk/pbuild/master.c index f602e2a98ae..a63445974e2 100644 --- a/pkgtools/pbulk/files/pbulk/pbuild/master.c +++ b/pkgtools/pbulk/files/pbulk/pbuild/master.c @@ -1,4 +1,4 @@ -/* $NetBSD: master.c,v 1.8 2009/01/31 23:25:38 joerg Exp $ */ +/* $NetBSD: master.c,v 1.9 2013/01/14 14:33:28 jperkin Exp $ */ /*- * Copyright (c) 2007, 2009 Joerg Sonnenberger . @@ -35,14 +35,12 @@ #include #include -#ifdef __sun -#include -#endif #include #include #include #include #include +#include #include #include #include @@ -308,10 +306,8 @@ master_mode(const char *master_port, const char *start_script) fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) err(1, "Could not create socket"); -#ifdef FIOCLEX - if (ioctl(fd, FIOCLEX, NULL) == -1) + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) err(1, "Could not set close-on-exec flag"); -#endif if (bind(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1) err(1, "Could not bind socket"); if (listen(fd, 5) == -1) diff --git a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c index 6244d8ae7c1..979fae7ee34 100644 --- a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c +++ b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c @@ -1,4 +1,4 @@ -/* $NetBSD: pbuild.c,v 1.5 2007/08/05 14:15:55 joerg Exp $ */ +/* $NetBSD: pbuild.c,v 1.6 2013/01/14 14:33:28 jperkin Exp $ */ /*- * Copyright (c) 2007 Joerg Sonnenberger . @@ -174,6 +174,7 @@ main(int argc, char **argv) int build_package(const char *build_info, size_t len) { + struct sigaction sa; int input[2]; pid_t child; @@ -210,6 +211,15 @@ build_package(const char *build_info, size_t len) return ret; } + /* Reset SIGPIPE handling for child */ +#if !defined(__INTERIX) + sa.sa_sigaction = NULL; +#endif + sa.sa_handler = SIG_DFL; + sa.sa_flags = 0; + (void)sigemptyset(&sa.sa_mask); + (void)sigaction(SIGPIPE, (struct sigaction *)&sa, NULL); + (void)close(input[1]); if (dup2(input[0], 0) == -1) { const char err_msg[] = "dup failed for stdin\n"; diff --git a/pkgtools/pbulk/files/pbulk/pscan/master.c b/pkgtools/pbulk/files/pbulk/pscan/master.c index 94221ee527c..598609cca84 100644 --- a/pkgtools/pbulk/files/pbulk/pscan/master.c +++ b/pkgtools/pbulk/files/pbulk/pscan/master.c @@ -1,4 +1,4 @@ -/* $NetBSD: master.c,v 1.7 2009/01/31 23:25:38 joerg Exp $ */ +/* $NetBSD: master.c,v 1.8 2013/01/14 14:33:28 jperkin Exp $ */ /*- * Copyright (c) 2007, 2009 Joerg Sonnenberger . @@ -36,14 +36,12 @@ #include #include #include -#ifdef __sun -#include -#endif #include #include #include #include #include +#include #include #include #include @@ -259,10 +257,8 @@ master_mode(const char *master_port, const char *start_script) fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) err(1, "Could not create socket"); -#ifdef FIOCLEX - if (ioctl(fd, FIOCLEX, NULL) == -1) + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) err(1, "Could not set close-on-exec flag"); -#endif if (bind(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1) err(1, "Could not bind socket"); if (listen(fd, 5) == -1) -- cgit v1.2.3