bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CVS Feature Branch - version - cannot write to stdout


From: Mark D. Baushke
Subject: Re: CVS Feature Branch - version - cannot write to stdout
Date: Mon, 11 Oct 2004 12:06:02 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Conrad T. Pino <Conrad@pino.com> writes:

> static void
> handle_m (char *args, int len)
> {
>     fd_set wfds;
>     int s;
> 
>     /* In the case where stdout and stderr point to the same place,
>        fflushing stderr will make output happen in the correct order.
>        Often stderr will be line-buffered and this won't be needed,
>        but not always (is that true?  I think the comment is probably
>        based on being confused between default buffering between
>        stdout and stderr.  But I'm not sure).  */
>     fflush (stderr);
>     FD_ZERO (&wfds);
>     FD_SET (STDOUT_FILENO, &wfds);
>     s = select (STDOUT_FILENO+1, NULL, &wfds, NULL, NULL);
>     fprintf( stderr, "WSAGetLastError test, s = %d\n", s );
>     if (s < 1)
>       {
>         int sockerr = WSAGetLastError( );
>         perror ("cannot write to stdout");
>         fprintf( stderr, "WSAGetLastError = %d\n", sockerr );
>       }
>     fwrite (args, len, sizeof (*args), stdout);
>     putc ('\n', stdout);
> }

Hmmm... I wish I had a better #define to use to control this behavior...
I suspect it may not be a problem in a cygwin environment, but I could
be wrong.

The following replacement functions should fix your problem (let me know
if it does not). If anyone has a 'better' way to deal with the problem,
please let me know...

static void
handle_m (char *args, size_t len)
{
#if !defined(HAVE_WINSOCK_H)
    fd_set wfds;
    int s;
#endif

    /* In the case where stdout and stderr point to the same place,
       fflushing stderr will make output happen in the correct order.
       Often stderr will be line-buffered and this won't be needed,
       but not always (is that true?  I think the comment is probably
       based on being confused between default buffering between
       stdout and stderr.  But I'm not sure).  */
    fflush (stderr);
#if !defined(HAVE_WINSOCK_H)
    FD_ZERO (&wfds);
    FD_SET (STDOUT_FILENO, &wfds);
    s = select (STDOUT_FILENO+1, NULL, &wfds, NULL, NULL);
    if (s < 1)
        perror ("cannot write to stdout");
#endif
    fwrite (args, len, sizeof (*args), stdout);
    putc ('\n', stdout);
}

/* ... */

static void
handle_e (char *args, size_t len)
{
#if !defined(HAVE_WINSOCK_H)
    fd_set wfds;
    int s;
#endif

    /* In the case where stdout and stderr point to the same place,
       fflushing stdout will make output happen in the correct order.  */
    fflush (stdout);
#if !defined(HAVE_WINSOCK_H)
    FD_ZERO (&wfds);
    FD_SET (STDERR_FILENO, &wfds);
    s = select (STDERR_FILENO+1, NULL, &wfds, NULL, NULL);
    /*
     * If stderr has problems, then adding a call to
     *   perror ("cannot write to stderr")
     * will not work. So, try to write a message on stdout and
     * terminate cvs.
     */
    if (s < 1)
        fperrmsg (stdout, 1, errno, "cannot write to stderr");
#endif
    fwrite (args, len, sizeof (*args), stderr);
    putc ('\n', stderr);
}

> Attempt with CVSHome.org server:
> 
> H:\cvs-1.12>windebug\cvs version
> Client: Concurrent Versions System (CVS) 1.12.9.1 (client)
> Server: WSAGetLastError test, s = -1
> cannot write to stdout: No error
> WSAGetLastError = 10038
> Concurrent Versions System (CVS) 1.11.15-scast-vc-1.5.2 (client/server)
> 
> H:\cvs-1.12>cd WinDebug
> ==================================
> Attempt with local LAN server:
> 
> H:\cvs-1.12\WinDebug>cvs version
> Client: Concurrent Versions System (CVS) 1.12.9.1 (client)
> Server: WSAGetLastError test, s = -1
> cannot write to stdout: No such file or directory
> WSAGetLastError = 10038
> Concurrent Versions System (CVS) 1.11.17 (client/server)
> 
> H:\cvs-1.12\WinDebug>
> ==================================
> Error code explanation:
> 
> WSAENOTSOCK = 10038, Socket operation on nonsocket. 
> 
> An operation was attempted on something that is not a socket.
> Either the socket handle parameter did not reference a valid
> socket, or for select, a member of an fd_set was not valid.  
> ==================================
> Conrad

        Thanks,
        -- Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFBatma3x41pRYZE/gRArH5AKCA8EGz3hWDfO8arKncNeY6/p0jlACeL+6M
tL2uMAAjQn7ykP7d2exiqcE=
=vBq+
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]