delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4DAE1051.7040500@redhat.com> |
Date: | Tue, 19 Apr 2011 16:44:33 -0600 |
From: | Eric Blake <eblake AT redhat DOT com> |
User-Agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110318 Red Hat/3.1.9-3.el6_0 Mnenhy/0.8.3 Thunderbird/3.1.9 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: 0417 snapshot: exec() fails on /proc/self/exe |
References: | <BANLkTimerprgbPRa1jMaTH4NY-F7_yz--w AT mail DOT gmail DOT com> |
In-Reply-To: | <BANLkTimerprgbPRa1jMaTH4NY-F7_yz--w@mail.gmail.com> |
OpenPGP: | url=http://people.redhat.com/eblake/eblake.gpg |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
--------------enig59D58569A19B7586B0FFF36C Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/19/2011 02:16 PM, Andy Koppe wrote: > int main(int argc, char *argv[]) > { > if (argc > 1 && !fork()) { > execl("/proc/self/exe", argv[0], (char *)0); > puts(strerror(errno)); > } > return 0; > } >=20 > $ cc test.c >=20 > $ ./a bla > Bad file descriptor >=20 > With 1.7.9, it prints nothing, which is the expected behaviour. > Looking at POSIX, EBADF is not a valid errno for exec(). EBADF is not listed for execl(), but _is_ listed for fexecve(), and when you consider that /proc/self is a special file system that opens file descriptors rather than files, it makes (a bit) of sense. At any rate, POSIX states that other errors than those documented (such as EBADF for execl()) may be returned if the condition for those errors matches other use of that errno value and does not skip over any existing mandated errors. It also means that maybe cygwin should behave as if O_EXEC rather than O_RDONLY were used when populating "/proc/self/exe", seeing as how execl() on that file basically boils down to an fexecve() call. --=20 Eric Blake eblake AT redhat DOT com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig59D58569A19B7586B0FFF36C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJNrhBRAAoJEKeha0olJ0Nqqs8H/j5428IcWZFNY2alG74wuUf5 1F+dNFdUec3dO+XpdBJAOaYow5++OJF138npC34zVy9gLy50Ty6fG611TDhjMed8 hzpGe/3OCX5Wsxsxm6pZzxq3ZXlvL84H2ftwNB3sZ7pd0oU03VRKPFIKMAZjEHdw mord6/DXjL9X64/mxRBgiiy9z9IFW8L2eUXja2nQJFLMmUXdxb6WNQdt7Y3Eps/Z TZHlJfxPSZuw1qPUh0thLtMK6OsAv/NocZXMccGJdFN/n/3Gg1+X69Bwx7XCkPwR 2L4y6kQkscD3WACi6egMP8LTp6IAaZ+jxuMURGEApQY3VdxjlUXkycWb+wAf/hs= =Lge4 -----END PGP SIGNATURE----- --------------enig59D58569A19B7586B0FFF36C--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |