From: Mark H Weaver <mhw@netris.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: ludo@gnu.org, guile-devel@gnu.org
Subject: Re: [PATCH] Implement open-process and related functions on MinGW
Date: Fri, 28 Feb 2014 05:20:11 -0500 [thread overview]
Message-ID: <87ob1ro7xg.fsf@yeeloong.lan> (raw)
In-Reply-To: <83vbvzwqke.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 28 Feb 2014 11:10:25 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Mark H Weaver <mhw@netris.org>
>> Cc: ludo@gnu.org, guile-devel@gnu.org
>> Date: Fri, 28 Feb 2014 02:22:19 -0500
>>
>> However, I don't want to use the "0xC0000200 + SIGNAL" convention
>> "between Guile and itself" that you've invented. Instead, based on what
>> you wrote, I guess that we should make WIFSIGNALED(x) return true for
>> any status code of the form 0xC0000xxx, or maybe some larger set. I
>> guess that WIFEXITED(x) should return the logical not of WIFSIGNALED(x).
>> WIFSTOPPED(x) presumably should always return false.
>>
>> In the code you wrote:
>>
>> > # define WIFEXITED(stat_val) (((stat_val) & 0xC0000000) == 0)
>> > # define WIFSIGNALED(stat_val) (((stat_val) & 0xC0000000) != 0)
>>
>> WIFSIGNALED(x) returns true if either of two high bits are 1. This
>> seems a bit too loose to me.
>
> Strictly speaking, any of these two bits or both of them could be set,
[...]
> In general, a
> program launched by Guile could have a debugger attached, and then it
> could potentially get an exception like 0x40010005 (Ctrl-C was pressed
> into a debugged program).
Okay, in that case perhaps the definitions above are the best ones.
I'll leave it to your best judgment what definitions are most likely to
be "future proof", i.e. to correctly distinguish normal exits from
abnormal termination in future versions of Windows.
>> IMO, it would be reasonable to just return SIGTERM in all cases, like
>> Gnulib does, but perhaps we should map some known values to specific
>> signals. You mentioned that the equivalent of SIGSEGV on Windows
>> results in a 0xC0000005 status code. Any others worth mapping?
>
> Are you still talking about a program that crashed, or are you talking
> about a program that Guile forcibly killed?
I think we should try to consider both of these cases, and also a third
case: programs that are forcibly killed by something other than Guile.
> My reasoning for not producing SIGTERM
> unconditionally was that it might be confusing for a Guile program
> that requested termination via some signal other than SIGTERM to see
> that the program was terminated by SIGTERM. I wanted WTERMSIG to
> return the same signal that was used to kill the program.
I suspect that this is relatively unimportant. I suspect that it's more
important to do our best to follow the status code conventions used on
Windows, because:
* When Guile kills a process, the status code of the killed process
should make sense to its parent, even if that parent is not Guile.
* When a Guile subprocess is killed by something other than Guile,
The Guile program should be able to make sense of the status code.
> As for mapping these values to Posix signals: yes, this is possible.
> Here's the suggested mapping of values I consider useful:
>
> 0xC0000005 (access to invalid address) SIGSEGV
> 0xC0000008 (invalid handle) SIGSEGV
> 0xC000001D (illegal instruction) SIGILL
> 0xC0000025 (non-continuable exception) SIGILL
> 0xC000008C (array bounds exceeded) SIGSEGV
> 0xC000008D (float denormal) SIGFPE
> 0xC000008E (float divide by zero) SIGFPE
> 0xC000008F (float inexact) SIGFPE
> 0xC0000090 (float invalid operation) SIGFPE
> 0xC0000091 (float overflow) SIGFPE
> 0xC0000092 (float stack check) SIGFPE
> 0xC0000093 (float underflow) SIGFPE
> 0xC0000094 (integer divide by zero) SIGFPE
> 0xC0000095 (integer overflow) SIGFPE
> 0xC0000096 (privileged instruction) SIGILL
> 0xC00000FD (stack overflow) SIGSEGV
> 0xC000013A (Ctrl-C exit) SIGINT
This looks good to me. We'll also have to decide what WTERMSIG should
return by default, when the status code is none of the values above.
Also, what if the top bits are something other than 0xCxxx? Should we
mask those off before looking up the code in the table above?
> You will see that there's no mapping for SIGTERM here. If having that
> is important, we could map the last one to SIGTERM, since a program is
> frequently forcibly terminated on Windows by simulating a Ctrl-C
> keypress to it.
Yes, I think that's probably wise.
BTW, on the stable-2.0 branch in git, I recently imported the following
modules from Gnulib:
link fsync readlink rename mkdir rmdir unistd
and removed the corresponding "#ifdef HAVE_xxx" around the associated
Scheme procedure definitions. For details, see:
http://git.savannah.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=3243fffcc19144fc0b30e983c3e50d1d1fc19ef4
http://git.savannah.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=ca6adcc6df462f325dfa7b099295fd6212d02b43
I nearly imported the 'pipe-posix' Gnulib module as well, but I noticed
that they implemented it differently than you did. You wrote:
> # define pipe(f) _pipe(f, 0, O_NOINHERIT)
Whereas they do: _pipe(f, 4096, _O_BINARY).
Can you help me understand the pros and cons to these two approaches?
One thing: I'm fairly sure that we'll want _O_BINARY, and I think we
should also make sure that the pipe buffer is no less than 4096 bytes.
What do you think?
Regards,
Mark
next prev parent reply other threads:[~2014-02-28 10:20 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <wrbvbwejihe.fsf@sspiff.org>
[not found] ` <wrbr471jxjg.fsf@sspiff.org>
[not found] ` <834n3x8o7m.fsf@gnu.org>
2014-02-17 20:59 ` [PATCH v2] Improved ^c support for gdb/guile Doug Evans
2014-02-17 21:13 ` Eli Zaretskii
2014-02-18 0:37 ` Doug Evans
2014-02-18 11:20 ` Ludovic Courtès
2014-02-18 16:01 ` Eli Zaretskii
2014-02-18 16:45 ` Ludovic Courtès
2014-02-18 16:56 ` Eli Zaretskii
2014-02-18 17:45 ` Ludovic Courtès
2014-02-18 17:59 ` Eli Zaretskii
2014-02-18 23:08 ` Ludovic Courtès
2014-02-18 17:32 ` MinGW patches Ludovic Courtès
2014-02-18 18:16 ` Eli Zaretskii
2014-02-22 10:33 ` [PATCH] Remove unneeded HAVE_POSIX conditionals Eli Zaretskii
2014-02-22 14:52 ` Mark H Weaver
2014-02-22 15:41 ` Eli Zaretskii
2014-02-26 21:42 ` Ludovic Courtès
2014-02-22 10:50 ` [PATCH] Implement open-process and related functions on MinGW Eli Zaretskii
2014-02-22 14:59 ` Mark H Weaver
2014-02-22 15:43 ` Eli Zaretskii
2014-02-22 15:54 ` Mark H Weaver
2014-02-22 16:35 ` Eli Zaretskii
2014-02-23 5:50 ` Mark H Weaver
2014-02-23 17:54 ` Eli Zaretskii
2014-02-24 18:33 ` Mark H Weaver
2014-02-24 21:06 ` Eli Zaretskii
2014-02-28 7:22 ` Mark H Weaver
2014-02-28 9:10 ` Eli Zaretskii
2014-02-28 10:20 ` Mark H Weaver [this message]
2014-02-28 11:26 ` Eli Zaretskii
2014-02-24 21:12 ` Eli Zaretskii
2014-02-22 18:20 ` Eli Zaretskii
2014-02-22 22:02 ` Mark H Weaver
2014-02-23 3:45 ` Eli Zaretskii
2014-02-23 4:40 ` Mark H Weaver
2014-02-23 17:46 ` Eli Zaretskii
2014-02-23 20:14 ` Mark H Weaver
2014-02-22 10:57 ` MinGW patches Eli Zaretskii
2014-02-22 12:23 ` Neil Jerram
2014-02-22 13:02 ` Eli Zaretskii
2014-02-22 11:06 ` Eli Zaretskii
2014-02-22 15:59 ` Mark H Weaver
2014-02-22 16:36 ` Eli Zaretskii
2014-02-23 14:21 ` Mark H Weaver
2014-02-23 18:06 ` Eli Zaretskii
2014-02-19 7:50 ` [PATCH v2] Improved ^c support for gdb/guile Mark H Weaver
2014-02-19 16:42 ` Eli Zaretskii
2014-02-18 17:31 ` Doug Evans
2014-02-18 17:42 ` Signal delivery Ludovic Courtès
2014-02-18 17:56 ` Doug Evans
2014-02-18 23:06 ` Ludovic Courtès
2014-02-19 1:58 ` Doug Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ob1ro7xg.fsf@yeeloong.lan \
--to=mhw@netris.org \
--cc=eliz@gnu.org \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).