Snapshot uploaded, please try

Brian Ford Brian.Ford@flightsafety.com
Thu Aug 17 23:38:00 GMT 2006


On Thu, 17 Aug 2006, Brian Ford wrote:
> On Thu, 10 Aug 2006, Christopher Faylor wrote:
> > On Thu, Aug 10, 2006 at 11:19:15PM +0200, Dr. Volker Zell wrote:
> > >Starting xterm from an rxvt window gives:
> > >In the Xterm window
> > > 587214 [main] xterm 296 modify_handle: virtual void fhandler_pipe::set_close_on_exec(bool):175 handle guard<0x680> not found
> >
> > That one *could* be responsible.  I was suspecting something in the pipe
> > code since it has often been the cause of handle closing confusion.
>
> Just in case anyone wants another simple test case:
>
> $ cat makefile
> all:
>         echo hi
>
> $ make
> echo hi
>    7486 [main] make 2648 modify_handle: virtual void
> fhandler_pipe::set_close_on_exec(bool):175 handle guard<0x734> not found
> hi

Attached is a simpler C test case distilled from the make code causing
the problem.

$ gcc -g -O2 -Wall pipe.c -o pipe.exe

$ ./pipe.exe
    788 [main] pipe 2332 modify_handle: virtual void
fhandler_pipe::set_close_on_exec(bool):175 handle guard<0x738> not found

-- 
Brian Ford
Lead Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained crew...
.

-------------- next part --------------
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int
main(void)
{
    int fds[2], flags;

    /* Make a file descriptor that is the read end of a broken pipe.
       This will be used for the childs standard input.  */

    if (pipe(fds) < 0)
    {
	perror("pipe");
	return -1;
    }

    /* Close the write side. */
    close (fds[1]);

    /* Set close on exec, so it does not litter the child's descriptor table.
       When it is dup2'd onto descriptor 0, that descriptor will not close
       on exec. */

    flags = fcntl(fds[0], F_GETFD, 0);

    if (flags < 0 || fcntl(fds[0], F_SETFD, flags|FD_CLOEXEC) < 0)
    {
	perror("close on exec");
	return -1;
    }

    switch (fork())
    {
    case (pid_t)-1:
	perror("fork failed");
	return -1;

    case 0: // child
        if (dup2(fds[0], 0) < 0) /* make stdin a broken pipe */
	{
	    perror("dup2 in");
	    _exit(-1);
	}

        execlp("ls", "ls", NULL);
	perror("exec ls");
	_exit(-1);

    default: // parent
        close(fds[0]);
    }

    return 0;
}
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list