This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 0417 snapshot: exec() fails on /proc/self/exe


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;
> }
> 
> $ cc test.c
> 
> $ ./a bla
> Bad file descriptor
> 
> 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.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]