From patchwork Mon Aug 16 04:19:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Lacombe X-Patchwork-Id: 119651 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7G4Sl5u004150 for ; Mon, 16 Aug 2010 04:28:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902Ab0HPE2q (ORCPT ); Mon, 16 Aug 2010 00:28:46 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:63818 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751627Ab0HPE2q (ORCPT ); Mon, 16 Aug 2010 00:28:46 -0400 Received: by gxk23 with SMTP id 23so1750426gxk.19 for ; Sun, 15 Aug 2010 21:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=bNkXuxWrU5sOFNmKfoXOWW9gu1iNBTIqV60FI/F5+k4=; b=Wa9qVpK78bjgUKRKxXcIy4U6gpQR9UVXMclUROmrOjsCQ0NwTS4PM3qShPELgWlAIK UaDJG6CgO830KRUeLKXZhozUqTeSl49UZGc7iVcydUChFA1/Zt7e4zPlyqu0z4gRYFqN Wbd3ZXZnJEVcCg2NAGfa+ksKEdcUOL589FCfM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=mMyws94JEb6BdoYHLe3Lpv4CuIEt85Kd+a5Hk8JP8Mqr5Wab1NAtpSVMlwf5lZDIpo YQgXBGupMF32KOwDqjoc9vjj4rZsEZ90UurFU27CC3YSB/W1+U8PikR5NN6b4AJGkxpO 3GJ4Ffnqe/Q/WhhkfSAogwx/zUX2StSOj5HGA= Received: by 10.151.39.10 with SMTP id r10mr37254ybj.310.1281932925706; Sun, 15 Aug 2010 21:28:45 -0700 (PDT) Received: from localhost.localdomain (206-248-183-141.dsl.teksavvy.com [206.248.183.141]) by mx.google.com with ESMTPS id q21sm4042821ybk.15.2010.08.15.21.28.43 (version=SSLv3 cipher=RC4-MD5); Sun, 15 Aug 2010 21:28:44 -0700 (PDT) From: Arnaud Lacombe To: Sam Ravnborg Cc: linux-kbuild , Arnaud Lacombe , Nir Tzachar Subject: [PATCH 1/4] kbuild: don't assign `stdout' and `stderr' Date: Mon, 16 Aug 2010 00:19:03 -0400 Message-Id: <1281932346-19067-1-git-send-email-lacombar@gmail.com> X-Mailer: git-send-email 1.7.2.30.gc37d7.dirty Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 16 Aug 2010 04:28:47 +0000 (UTC) diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 2ba71bc..e08a064 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -709,25 +709,6 @@ static const char *set_config_filename(const char *config_filename) return menu_backtitle; } -/* command = 0 is supress, 1 is restore */ -static void supress_stdout(int command) -{ - static FILE *org_stdout; - static FILE *org_stderr; - - if (command == 0) { - org_stdout = stdout; - org_stderr = stderr; - stdout = fopen("/dev/null", "a"); - stderr = fopen("/dev/null", "a"); - } else { - fclose(stdout); - fclose(stderr); - stdout = org_stdout; - stderr = org_stderr; - } -} - /* return = 0 means we are successful. * -1 means go on doing what you were doing */ @@ -753,9 +734,7 @@ static int do_exit(void) /* if we got here, the user really wants to exit */ switch (res) { case 0: - supress_stdout(0); res = conf_write(filename); - supress_stdout(1); if (res) btn_dialog( main_window, @@ -1449,9 +1428,7 @@ static void conf_save(void) case 0: if (!dialog_input_result[0]) return; - supress_stdout(0); res = conf_write(dialog_input_result); - supress_stdout(1); if (!res) { char buf[1024]; sprintf(buf, "%s %s", @@ -1495,6 +1472,8 @@ void setup_windows(void) int main(int ac, char **av) { char *mode; + FILE *fp; + int fd; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -1509,8 +1488,25 @@ int main(int ac, char **av) single_menu_mode = 1; } + /* Duplicate stdout before redirecting it */ + fd = dup(STDOUT_FILENO); + if (fd < 0) { + perror("dup"); + return 1; + } + + fp = fdopen(fd, "a"); + if (fp == NULL) { + perror("fdopen"); + return 1; + } + + freopen("/dev/null", "a", stdout); + freopen("/dev/null", "a", stderr); + /* Initialize curses */ - initscr(); + newterm(NULL, fp, stdin); + /* set color theme */ set_colors(); @@ -1521,7 +1517,7 @@ int main(int ac, char **av) if (COLS < 75 || LINES < 20) { endwin(); - printf("Your terminal should have at " + fprintf(fp, "Your terminal should have at " "least 20 lines and 75 columns\n"); return 1; }