On Tue, 1 Jun 2021 at 11:08, Chavdar Ivanov <ci4...@gmail.com> wrote: > > Fails under FreeBSD 13 as well: > > root@f13:~xci # touch foo.txt > root@f13:~xci # cc -o s s.c > root@f13:~xci # ./s > fd = 3 > new_fd = -1 > root@f13:~xci # uname -a > FreeBSD f13 13.0-RELEASE FreeBSD 13.0-RELEASE #0 > releng/13.0-n244733-ea31abc261f: Fri Apr 9 04:24:09 UTC 2021 > r...@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC > amd64
And under OpenBSD likewise: o64q$ gcc -o s s.c /tmp//ccoGvFqD.o: In function `main': s.c:(.text+0x6a): warning: sprintf() is often misused, please use snprintf() o64q$ touch foo.txt o64q$ ./s fd = 3 new_fd = -1 o64q$ uname -a OpenBSD o64q.lorien.lan 6.4 GENERIC.MP#2 amd64 So there is a theme, I guess... > > > On Tue, 1 Jun 2021 at 10:54, Chavdar Ivanov <ci4...@gmail.com> wrote: > > > > On Tue, 1 Jun 2021 at 10:13, Martin Husemann <mar...@duskware.de> wrote: > > > > > > On Tue, Jun 01, 2021 at 10:03:50AM +0100, Chavdar Ivanov wrote: > > > > Succeeds for me: > > > > ... > > > > ? ~ gcc -o s s.c > > > > ? ~ ./s > > > > fd = -1 > > > > new_fd = -1 > > > > > > You need to touch foo.txt upfront, that will make the first open work, but > > > the second fail: > > > > > > > ./a.out > > > fd = 3 > > > new_fd = -1 > > > > > > > > > ... so I can reproduce the issue. I am not sure this shold succeed, but it > > > is a gray area (and semantics for procfs are not well defined). > > > > Same; I've mistyped 'foo.tx' in the touch command. > > > > > > > > Martin > > > > > > > > -- > > ---- > > > > -- > ---- -- ----