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

Re: 20050322: EXEC stderr output getting into PIPE results?



Steven,

>Date: Wed, 23 Mar 2005 14:16:45 -0600
>From: "Steven Danz" <address@hidden>
>Organization: Aviation Weather Center
>To: Steve Emmerson <address@hidden>
>Subject: Re: 20050322: EXEC stderr output getting into PIPE results?

The above message contained the following:

> Um, not quite. The
> 
> 0 != strcmp(logfname, "-")
> 
> is saying that if the log file is set to anything -other- than '-' then 
> stderr is closed and stderrIsValid is set to 0
> so no one gets to use the logfile if one is given on the command line.  
> I've show this to be true on our
> evaluation server.  I've attached a patch that I _think_ gets things 
> back to 'normal', at least it works
> for me.

&%$#@!

You're quite right.

Use your patch.  I'll make sure the next release is fixed.

> Steven Danz
> Senior Software Development Engineer
> Aviation Weather Center (NOAA/NWS/NCEP)
> 7220 NW 101st Terrace, Room 101
> Kansas City, MO 64153-2371
> 
> Email: address@hidden
> Phone: 816.584.7251
> Fax:   816.880.0650
> URL:   http://aviationweather.gov/
> 
> The opinions expressed in this message do not necessarily reflect those 
> of the National Weather Service, or the Aviation Weather Center.
> 
> 
> --------------020605070405030308050301
> Content-Type: text/plain;
>  name="pqact.c.patch"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
>  filename="pqact.c.patch"
> 
> --- pqact.c.orig      2005-03-23 20:06:53.000000000 +0000
> +++ pqact.c   2005-03-23 20:10:02.000000000 +0000
> @@ -226,6 +226,8 @@
>          prod_spec spec;
>          prod_class clss;
>          int toffset = TOFFSET_NONE;
> +        int logFd;
> +        int origStderr;
>  
>          conffilename = DEFAULT_CONFFILENAME;
>  
> @@ -330,16 +332,36 @@
>          }
>  
>          /*
> +         * Close stderr if we are going to attempt to reassign it 
> +         * to the log file
> +         */
> +        if (NULL == logfname || 0 != strcmp(logfname, "-")) {
> +                origStderr = fileno(stderr);
> +                (void)fclose(stderr);
> +                stderrIsValid = 0;
> +        }
> +
> +        /*
> +         * Initialize logging.
> +         */
> +        logFd = openulog(ubasename(av[0]),
> +                (LOG_CONS|LOG_PID), LOG_LDM, logfname);
> +        unotice("Starting Up");
> +
> +        /*
> +         * If the log was placed on stderr, then allow others to use it
> +         */
> +        if (logFd == origStderr) {
> +                stderrIsValid = 1;
> +        }
> +
> +        /*
>           * Close as many file descriptors as possible (consonant with 
> logging)
>           * so that the maximum number will be available for actions like FILE
>           * and PIPE.
>           */
>          (void)fclose(stdin);
>          (void)fclose(stdout);
> -        if (NULL == logfname || 0 != strcmp(logfname, "-")) {
> -                (void)fclose(stderr);
> -                stderrIsValid = 0;
> -        }
>  
>          /*
>           * Inform the "filel" module about the number of available file
> @@ -353,13 +375,6 @@
>          }
>  
>          /*
> -         * Initialize logging.
> -         */
> -        (void)openulog(ubasename(av[0]),
> -                (LOG_CONS|LOG_PID), LOG_LDM, logfname);
> -        unotice("Starting Up");
> -
> -        /*
>           * Compile the pattern.
>           */
>          if (re_isPathological(spec.pattern))
> 
> --------------020605070405030308050301--

Regards,
Steve Emmerson