From owner-svn-src-all@FreeBSD.ORG Sun Jun 6 11:36:09 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FDCC1065670; Sun, 6 Jun 2010 11:36:09 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 257678FC0C; Sun, 6 Jun 2010 11:36:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o56Ba9pu029720; Sun, 6 Jun 2010 11:36:09 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o56Ba9tr029717; Sun, 6 Jun 2010 11:36:09 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201006061136.o56Ba9tr029717@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 6 Jun 2010 11:36:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208868 - in head/usr.bin: bc dc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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, 06 Jun 2010 11:36:09 -0000 Author: gabor Date: Sun Jun 6 11:36:08 2010 New Revision: 208868 URL: http://svn.freebsd.org/changeset/base/208868 Log: - Fix signal handling in bc/dc. Now Ctrl-C terminates the execution. Requested by: gk (via private mail) Approved by: delphij (mentor) Modified: head/usr.bin/bc/scan.l head/usr.bin/dc/bcode.c Modified: head/usr.bin/bc/scan.l ============================================================================== --- head/usr.bin/bc/scan.l Sun Jun 6 11:32:38 2010 (r208867) +++ head/usr.bin/bc/scan.l Sun Jun 6 11:36:08 2010 (r208868) @@ -23,7 +23,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -235,22 +234,6 @@ add_str(const char *str) strlcat(strbuf, str, strbuf_sz); } -/* ARGSUSED */ -void -abort_line(int sig) -{ - static const char str[] = "[\n]P\n"; - int save_errno; - - switch (sig) { - default: - save_errno = errno; - YY_FLUSH_BUFFER; /* XXX signal race? */ - write(STDOUT_FILENO, str, sizeof(str) - 1); - errno = save_errno; - } -} - int yywrap(void) { @@ -288,8 +271,6 @@ yywrap(void) } else if (fileindex == sargc) { fileindex++; yyin = stdin; - if (interactive) - signal(SIGINT, abort_line); lineno = 1; filename = "stdin"; return (0); Modified: head/usr.bin/dc/bcode.c ============================================================================== --- head/usr.bin/dc/bcode.c Sun Jun 6 11:32:38 2010 (r208867) +++ head/usr.bin/dc/bcode.c Sun Jun 6 11:36:08 2010 (r208868) @@ -44,7 +44,6 @@ struct bmachine { struct source *readstack; struct stack *reg; struct stack stack; - volatile sig_atomic_t interrupted; u_int scale; u_int obase; u_int ibase; @@ -55,7 +54,7 @@ struct bmachine { }; static struct bmachine bmachine; -static void sighandler(int); +static void got_sigint(int); static __inline int readch(void); static __inline void unreadch(void); @@ -223,14 +222,11 @@ static const struct jump_entry jump_tabl (sizeof(jump_table_data)/sizeof(jump_table_data[0])) static void -sighandler(int ignored) +got_sigint(int ignored __unused) { - switch (ignored) - { - default: - bmachine.interrupted = true; - } + putchar('\n'); + exit(0); } void @@ -265,7 +261,7 @@ init_bmachine(bool extended_registers) bmachine.obase = bmachine.ibase = 10; BN_init(&zero); bn_check(BN_zero(&zero)); - signal(SIGINT, sighandler); + signal(SIGINT, got_sigint); } /* Reset the things needed before processing a (new) file */ @@ -1746,14 +1742,6 @@ eval(void) bmachine.readsp--; continue; } - if (bmachine.interrupted) { - if (bmachine.readsp > 0) { - src_free(); - bmachine.readsp--; - continue; - } else - bmachine.interrupted = false; - } #ifdef DEBUGGING fprintf(stderr, "# %c\n", ch); stack_print(stderr, &bmachine.stack, "* ",