Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 10533 invoked from network); 22 Aug 2006 18:20:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Aug 2006 18:20:25 -0000 Received: (qmail 21130 invoked by uid 500); 22 Aug 2006 18:20:25 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 21115 invoked by uid 500); 22 Aug 2006 18:20:25 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 21104 invoked by uid 99); 22 Aug 2006 18:20:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Aug 2006 11:20:25 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.82.213.172] (HELO exkiv.kyiv.vdiweb.com) (212.82.213.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Aug 2006 11:20:24 -0700 Received: from [10.11.37.198] ([10.11.37.198]) by exkiv.kyiv.vdiweb.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 22 Aug 2006 21:20:21 +0300 Message-ID: <44EB4AE7.905@kyiv.vdiweb.com> Date: Tue, 22 Aug 2006 21:20:23 +0300 From: Farid Zaripov User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: [PATCH] exec utility patch Content-Type: multipart/mixed; boundary="------------040605050403010803090708" X-OriginalArrivalTime: 22 Aug 2006 18:20:21.0593 (UTC) FILETIME=[A1189C90:01C6C617] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------040605050403010803090708 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit The message box, displayed by the system debugger (drwtsn32.exe on WinNT or dwwin.exe on WinXP) in case when the child process causes Access Violation, remains on the screen after the child process is terminated by the exec utility. Attached is a patch for the exec utility to prevent displaying error message box when child causes access violation. This patch do not prevent the displaying of the message box on assertion fail, but this message box is not a big problem, because of it's disappear when child process terminates. ChangeLog: * exec.cpp [_WIN32 || _WIN64] (exec_file): Set appropriate error mode before running the child process to disable displaying the critical-error-handler and general-protection-fault message boxes. * runall.cpp [_WIN32 || _WIN64] : Included windows.h and signal.h. (process_results): Handle returned status STATUS_ACCESS_VIOLATION and print status "SEGV". Farid. --------------040605050403010803090708 Content-Type: text/plain; name="utils.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="utils.patch" Index: exec.cpp =================================================================== --- exec.cpp (revision 433620) +++ exec.cpp (working copy) @@ -930,6 +930,11 @@ merged = merge_argv (argv); + /* set appropriate error mode (the child process inherits this + error mode) to disable displaying the critical-error-handler + and general-protection-fault message boxes */ + UINT old_mode = SetErrorMode (SEM_FAILCRITICALERRORS + | SEM_NOGPFAULTERRORBOX); /* Create the child process */ if (0 == CreateProcess (argv [0], merged, 0, 0, 1, CREATE_NEW_PROCESS_GROUP, 0, 0, &context, &child)) { @@ -938,6 +943,9 @@ status.error = warn_last_error ("Creating child process");; } + /* restore the previous error mode */ + SetErrorMode (old_mode); + /* Clean up handles */ if (context.hStdInput) if (0 == CloseHandle (context.hStdInput)) Index: runall.cpp =================================================================== --- runall.cpp (revision 433620) +++ runall.cpp (working copy) @@ -35,6 +35,9 @@ #include #if !defined (_WIN32) && !defined (_WIN64) # include /* for WIFEXITED(), ... */ +#else +# include /* for STATUS_ACCESS_VIOLATION */ +# include /* for SIGSEGV */ #endif #include "cmdopt.h" @@ -256,7 +259,7 @@ size_t target_len = strlen (target_name); size_t tmp_len = path_len + target_len - 2; /* - 2 comes from removing 4 characters (extra .exe) and - adding 2 characters (\ directory seperator and trailing + adding 2 characters (\ directory separator and trailing null) */ tmp_name = (char*)RW_MALLOC (tmp_len); memcpy (tmp_name, target, path_len - 4); @@ -305,7 +308,7 @@ - n\n Child exited with the non-zero return code n - name\n - Child terminated upon recieving the signal SIGname + Child terminated upon receiving the signal SIGname @param target the path to the executable that was run @param exec_name the short name of the executable @@ -350,6 +353,8 @@ puts (" I/O"); else if (result->error) puts ("KILLED"); + else if (STATUS_ACCESS_VIOLATION == result->status) + printf ("%6s\n", get_signame (SIGSEGV)); else printf ("%6d\n", result->status); #endif /* _WIN{32,64} */ @@ -363,7 +368,7 @@ @warning this method is UTF-8 unsafe @warning this method assumes there are no trailing slashes in the path name - @warning this method retuns a pointer referencing a position inside the + @warning this method returns a pointer referencing a position inside the provided path. As such, the returned string isn't a new string, but rather an alias to the provided string. @param path path name to determine the basename for @@ -430,11 +435,11 @@ Entry point to the application. Passes arguments to the option processing subsystem, then processes all - remaing arguments as targets using run_target + remaining arguments as targets using run_target - @param argc number of arguments recieved - @param argv array of arguments recieved - @return 0 upon successfull completeion of execution + @param argc number of arguments received + @param argv array of arguments received + @return 0 upon successful completeion of execution */ int --------------040605050403010803090708--