[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Support open-process and friends on MS-Windows
From: |
Ludovic Courtès |
Subject: |
Re: Support open-process and friends on MS-Windows |
Date: |
Fri, 24 Jun 2016 13:49:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eli Zaretskii <address@hidden> skribis:
> commit 44f8eebf9850431790b23b031f5b6e90fb3de777
> Author: Eli Zaretskii <address@hidden>
> Date: Fri Jun 24 12:45:02 2016 +0300
>
> Provide support for open-process and related functions on MS-Windows
>
> * libguile/w32-proc.c: New file, with MinGW support code for
> scm_open_process, scm_getpriority, scm_setpriority,
> scm_getaffinity, and scm_setaffinity. Also, provides macros that
> on Posix hosts are in sys/wait.h, like WIFEXITED and WTERMSIG, and
> simple definitions for getuid, getgid, setuid, setgid, and
> waitpid.
This is a good idea (I cannot comment on the content of w32-proc.c since
I’m not familiar with the Windows API, but I obviously trust you).
> diff --git a/libguile/posix.c b/libguile/posix.c
> index 2654716..35b920f 100644
> --- a/libguile/posix.c
> +++ b/libguile/posix.c
> @@ -84,6 +84,10 @@
> #if HAVE_SYS_WAIT_H
> # include <sys/wait.h>
> #endif
> +#ifdef __MINGW32__
> +# include "w32-proc.c"
> +#endif /* __MINGW32__ */
I’d have a slight preference for using AC_LIBSOURCE or a Makefile.am
snippet to compile w32-proc.c separately (which means w32-proc.h should
be added to provide declarations).
However this shouldn’t be a blocker (if the current approach is kept,
use <w32-proc.c> rather than "w32-proc.c").
> @@ -659,7 +663,7 @@ SCM_DEFINE (scm_kill, "kill", 2, 0, 0,
> #else
> /* Mingw has raise(), but not kill(). (Other raw DOS environments might
> be similar.) Use raise() when the requested pid is our own process,
> - otherwise bomb. */
> + otherwise TerminateProcess. */
> if (scm_to_int (pid) == getpid ())
> {
> if (raise (scm_to_int (sig)) != 0)
> @@ -673,6 +677,25 @@ SCM_DEFINE (scm_kill, "kill", 2, 0, 0,
> goto err;
> }
> }
> +#ifdef __MINGW32__
> + else
> + {
> + HANDLE ph = OpenProcess (PROCESS_TERMINATE, 0, scm_to_int (pid));
> + int s = scm_to_int (sig);
> +
> + if (!ph)
> + {
> + errno = EPERM;
> + goto err;
> + }
> + if (!TerminateProcess (ph, w32_signal_to_status (s)))
> + {
> + errno = EINVAL;
> + goto err;
> + }
> + CloseHandle (ph);
> + }
> +#endif /* __MINGW32__ */
> #endif
> return SCM_UNSPECIFIED;
For consistency maybe this should go in a ‘kill’ function in w32-proc.c?
The rest looks good to me.
Thanks a lot for taking the time to update the patch, and for forgiving
our failure to handle it earlier.
Ludo’.
- Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/24
- Re: Support open-process and friends on MS-Windows, Andy Wingo, 2016/06/24
- Re: Support open-process and friends on MS-Windows,
Ludovic Courtès <=
- Re: Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/24
- Re: Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Andy Wingo, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Ludovic Courtès, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Andy Wingo, 2016/06/25
- Re: Support open-process and friends on MS-Windows, Eli Zaretskii, 2016/06/25