Re: posix_spawn[p]: Don't execute scripts without '#!' marker through /bin/sh

2020-12-24 Thread Bruno Haible
The new tests/test-spawn-pipe-script.c test reveals that create_pipe_in returns an odd errno value when the program is an executable script without '#!' marker. This patch fixes it. 2020-12-24 Bruno Haible findprog-in: Improve errno upon failure on native Windows. * lib/findpr

[PATCH 0/5] Fix multiple realpath issues

2020-12-24 Thread Adhemerval Zanella
This is an updated version of my previous set to fix multiple realpath implementation issues [1]. For this version I used the most recent gnulib version to sync, since it constains multiple issues and it fixes glibc BZ #10635, BZ #26592, and BZ #26241. However, the gnulib version shows some regre

[PATCH 3/5] Import filename.h from gnulib

2020-12-24 Thread Adhemerval Zanella
And use to simplify stdlib/canonicalize.c implementation. --- include/filename.h| 110 ++ stdlib/canonicalize.c | 5 +- 2 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 include/filename.h diff --git a/include/filename.h b/include

[PATCH 4/5] stdlib: Add testcase fro BZ #26241

2020-12-24 Thread Adhemerval Zanella
Checked on x86_64-linux-gnu and i686-linux-gnu. --- stdlib/Makefile | 3 +- stdlib/tst-canon-bz26341.c| 108 ++ support/support_set_small_thread_stack_size.c | 12 +- support/xthread.h | 2 + 4 files

[PATCH 1/5] stdlib: Sync canonicalize with gnulib [BZ #10635] [BZ #26592] [BZ #26241]

2020-12-24 Thread Adhemerval Zanella
It sync with gnulib version d9c121346 with the following difference require fix a glibc build: --- ../../gnulib/gnulib-lib/lib/canonicalize-lgpl.c +++ stdlib/canonicalize.c @@ -46,7 +46,7 @@ # define FILE_SYSTEM_PREFIX_LEN(name) 0 # define IS_ABSOLUTE_FILE_NAME(name) ISSLASH(*(name)) # define I

[PATCH 2/5] Import idx.h from gnulib

2020-12-24 Thread Adhemerval Zanella
And use to simplify stdlib/canonicalize.c implementation. --- include/idx.h | 113 ++ stdlib/canonicalize.c | 5 +- 2 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 include/idx.h diff --git a/include/idx.h b/include/idx.h new

[PATCH 5/5] stdlib: Remove lstat usage from realpath [BZ #24970]

2020-12-24 Thread Adhemerval Zanella
The readlink already tells whether the file is a symlink, so there is no need to call lstat to check it. However for '..' it requires an extra readlink check if the previous component can be really accessed, otherwise the next iteration will check a possible valid path and end early. It should pe

Re: posix_spawn[p]: Don't execute scripts without '#!' marker through /bin/sh

2020-12-24 Thread Bruno Haible
I wrote: > The new tests/test-spawn-pipe-script.c test reveals that create_pipe_in > returns an odd errno value when the program is an executable script without > '#!' marker. This patch fixes it. That patch fixed only the case when the program base name does not contain a '.'. When it does contai

execute: Treat signalled processes like wait-process does

2020-12-24 Thread Bruno Haible
When a child process terminates through a signal, the convention in posix_spawn is that the parent process sees an exit code of 127. This convention should also hold for the 'execute' module. On native Windows, this requires mapping the exit code 3 (from Microsoft) to exit code 127 (per POSIX). 2

Re: [PATCH 1/6] canonicalize-lgpl: fix EOVERFLOW bug

2020-12-24 Thread Paul Eggert
On 12/18/20 6:13 AM, Adhemerval Zanella wrote: The same tests I pointed out on BZ#24970 comment #2 still fails with gnulib version 0aa8ef424. I finally got some time free to look at this, and came up with some patches that should fix that problem, along with some others I noticed while in the

posix_spawn[p]: implement for native Windows

2020-12-24 Thread Bruno Haible
The attached patches implement posix_spawn and posix_spawnp for native Windows. To my knowledge, it's a world's first. While the posix_spawn facility was designed to be portable to other operating systems [1], the mingw people did not and do not provide it. [1] https://pubs.opengroup.org/onlinepu

Re: [PATCH 1/5] stdlib: Sync canonicalize with gnulib [BZ #10635] [BZ #26592] [BZ #26241]

2020-12-24 Thread Paul Eggert
On 12/24/20 7:16 AM, Adhemerval Zanella wrote: It sync with gnulib version d9c121346 with the following difference require fix a glibc build: As I mentioned today on bug-gnulib I installed some changes into Gnulib which are related, and it'd probably be better to sync with the latest version.

[PATCH] canonicalize-lgpl: merge proposed libc changes

2020-12-24 Thread Paul Eggert
This merges the changes proposed for glibc in: https://sourceware.org/pipermail/libc-alpha/2020-December/121085.html https://sourceware.org/pipermail/libc-alpha/2020-December/121086.html * lib/canonicalize-lgpl.c: Include idx.h and filename.h unconditionally. (idx_t, IDX_MAX, FILE_SYSTEM_PREFIX_LEN

Re: [PATCH 2/5] Import idx.h from gnulib

2020-12-24 Thread Paul Eggert
Thanks, this looks good. Also, the following "[PATCH 3/5] Import filename.h from gnulib" looks good. I merged both changes into Gnulib here: http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=1013adf6bf48627f84a9043cf2631ff13d2a452f

Re: [PATCH 5/5] stdlib: Remove lstat usage from realpath [BZ #24970]

2020-12-24 Thread Paul Eggert
This email finishes the review of this proposed glibc patchset. (I didn't look at patch 4/5 for test cases.) On 12/24/20 7:17 AM, Adhemerval Zanella wrote: +/* Check if BUFFER is using the internal buffer. */ +static __always_inline bool +scratch_buffer_using_internal (struct scratch_buffer *

Re: [PATCH 1/5] warnings in canonicalize.c

2020-12-24 Thread Bruno Haible
Paul Eggert wrote: > > @@ -270,7 +270,7 @@ > > buf[n] = '\0'; > > > > char *extra_buf = extra_buffer.data; > > - idx_t end_idx; > > + idx_t end_idx = 0; > > if (end_in_extra_buffer) > > end_idx = end - extr

execute, spawn-pipe: Use posix_spawn by default on native Windows

2020-12-24 Thread Bruno Haible
Now that posix_spawn works on native Windows, the modules 'execute' and 'spawn-pipe' can be changed to use this as the new implementation (instead of 'spawnvech', which implements only a special case). This new implementation surely allocates more temporary memory, and also calls DuplicateHandle m

Re: [PATCH 1/5] warnings in canonicalize.c

2020-12-24 Thread Paul Eggert
On 12/24/20 4:44 PM, Bruno Haible wrote: Indeed, I don't see warnings in canonicalize-lgpl.c. But there are warnings in gnulib's canonicalize.c: Thanks, I fixed those, along one or two others I noticed when compiling with GCC (Ubuntu 10.2.0-13ubuntu1). Even though I didn't get these warnings