From owner-svn-src-all@FreeBSD.ORG Sun Sep 1 19:59:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DCD3695D; Sun, 1 Sep 2013 19:59:54 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C94622275; Sun, 1 Sep 2013 19:59:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r81Jxsdj045748; Sun, 1 Sep 2013 19:59:54 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r81Jxs8Z045747; Sun, 1 Sep 2013 19:59:54 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201309011959.r81Jxs8Z045747@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 1 Sep 2013 19:59:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255129 - head/lib/libc/stdlib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Sep 2013 19:59:54 -0000 Author: jilles Date: Sun Sep 1 19:59:54 2013 New Revision: 255129 URL: http://svnweb.freebsd.org/changeset/base/255129 Log: system(): Restore behaviour for SIGINT and SIGQUIT. As mentioned in r16117 and the book "Advanced Programming in the Unix Environment" by W. Richard Stevens, we should ignore SIGINT and SIGQUIT before forking, since it is not guaranteed that the parent process starts running soon enough. To avoid calling sigaction() in the vforked child, instead block SIGINT and SIGQUIT before vfork() and keep the sigaction() to ignore after vfork(). The FreeBSD kernel discards ignored signals, even if they are blocked; therefore, it is not necessary to unblock SIGINT and SIGQUIT earlier. Modified: head/lib/libc/stdlib/system.c Modified: head/lib/libc/stdlib/system.c ============================================================================== --- head/lib/libc/stdlib/system.c Sun Sep 1 19:27:32 2013 (r255128) +++ head/lib/libc/stdlib/system.c Sun Sep 1 19:59:54 2013 (r255129) @@ -59,6 +59,8 @@ __system(const char *command) (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); + (void)sigaddset(&newsigblock, SIGINT); + (void)sigaddset(&newsigblock, SIGQUIT); (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); switch(pid = vfork()) { case -1: /* error */