From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.lisp.guile.devel Subject: Re: Support open-process and friends on MS-Windows Date: Sat, 25 Jun 2016 18:01:10 +0300 Message-ID: <83k2hdz51l.fsf@gnu.org> References: <834m8i3off.fsf@gnu.org> <877fde958i.fsf@gnu.org> <83wple1zym.fsf@gnu.org> <83ziq9zl8l.fsf@gnu.org> <87eg7lbnpi.fsf@pobox.com> <83y45tzhyn.fsf@gnu.org> <87twghs9ot.fsf@gnu.org> <83r3blz96w.fsf@gnu.org> <87a8i9ba7d.fsf@pobox.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1466866945 27234 80.91.229.3 (25 Jun 2016 15:02:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Jun 2016 15:02:25 +0000 (UTC) Cc: ludo@gnu.org, guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jun 25 17:02:20 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bGp69-0001Ed-Jx for guile-devel@m.gmane.org; Sat, 25 Jun 2016 17:02:17 +0200 Original-Received: from localhost ([::1]:50296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGp65-0003nK-Cx for guile-devel@m.gmane.org; Sat, 25 Jun 2016 11:02:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGp5r-0003nE-PY for guile-devel@gnu.org; Sat, 25 Jun 2016 11:02:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGp5q-0002DK-MW for guile-devel@gnu.org; Sat, 25 Jun 2016 11:01:59 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGp5l-0002BR-RK; Sat, 25 Jun 2016 11:01:53 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1830 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bGp5k-0004H2-N3; Sat, 25 Jun 2016 11:01:53 -0400 In-reply-to: <87a8i9ba7d.fsf@pobox.com> (message from Andy Wingo on Sat, 25 Jun 2016 16:43:34 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18435 Archived-At: > From: Andy Wingo > Cc: ludo@gnu.org (Ludovic Courtès), guile-devel@gnu.org > Date: Sat, 25 Jun 2016 16:43:34 +0200 > > > @@ -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,10 @@ SCM_DEFINE (scm_kill, "kill", 2, 0, 0, > > goto err; > > } > > } > > +#ifdef __MINGW32__ > > + if (w32_kill_proc (scm_to_int (pid), scm_to_int (sig)) != 0) > > + SCM_SYSERROR; > > +#endif /* __MINGW32__ */ > > #endif > > return SCM_UNSPECIFIED; > > } > > Here we effectively have two mingw blocks. Can the previous one be > removed? The previous block is not MinGW-specific. It allows any system that has 'raise' (which is Standard C, so should be available everywhere) to at least kill the current process. This code was there before my changes, and I saw no reasons to remove it. > If not, let's fold it into `w32_kill_proc', and in any case > let's rename `w32_kill_proc' to `kill', and then define HAVE_KILL. I didn't want to call the function 'kill', as some other linked-in library might have it, and then you'd have a clash. 'kill' is too simple a name to overload. > > @@ -1141,7 +1143,7 @@ SCM_DEFINE (scm_execl, "execl", 1, 0, 1, > > > > exec_argv = scm_i_allocate_string_pointers (args); > > > > - execv (exec_file, exec_argv); > > + execv (exec_file, (char const * const *)exec_argv); > > SCM_SYSERROR; > > > > /* not reached. */ > > make[3]: Entering directory '/home/wingo/src/guile-2.0/libguile' > CC libguile_2.0_la-posix.lo > posix.c: In function 'scm_execl': > posix.c:1146:21: warning: passing argument 2 of 'execv' from incompatible pointer type [-Wincompatible-pointer-types] > execv (exec_file, (char const * const *)exec_argv); > ^ > In file included from ../lib/unistd.h:40:0, > from posix.c:50: > /home/wingo/.guix-profile/include/unistd.h:566:12: note: expected 'char * const*' but argument is of type 'const char * const*' > extern int execv (const char *__path, char *const __argv[]) > ^~~~~ > > What should be done here? Make the cast MinGW-only? > > @@ -1408,16 +1433,16 @@ scm_open_process (SCM mode, SCM prog, SCM args) > > if (err > 0) > > { > > char *msg = strerror (errno); > > - fprintf (fdopen (err, "a"), "In execlp of %s: %s\n", > > + fprintf (fdopen (err, "a"), "In execvp of %s: %s\n", > > exec_file, msg); > > } > > > > _exit (EXIT_FAILURE); > > +#endif /* HAVE_FORK */ > > /* Not reached. */ > > return SCM_BOOL_F; > > } > > #undef FUNC_NAME > > -#endif /* HAVE_FORK */ > > This change updates to provide `open-process' effectively on all systems > instead of only if `fork' is available, but then it causes a runtime > error if the system doesn't have `fork' and isn't `mingw32'. Sorry, I don't follow: the change in fprintf fixes a simple type (the function whose call failed is 'execvp', not 'execlp'. Or are you talking about something else? > I guess that's OK in practice. Would you mind updating the > documentation in doc/ref/posix.texi to indicate this? Thanks. Once I understand the issue, sure. Thanks.