bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed bug on seekable stdin


From: Ralf Wildenhues
Subject: Re: sed bug on seekable stdin
Date: Sun, 17 Dec 2006 13:31:41 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Paolo Bonzini wrote on Sun, Dec 17, 2006 at 10:36:17AM CET:
> 
> >The solution is simple - before any use of exit(EXIT_SUCCESS) (or before
> >returning from main), you must ensure that you call fclose(stdin).
> 
> Can you check out the attached patch on CVS or 4.1b sed?

FWIW, Eric's test passes for me with CVS sed without or with the patch
below, on GNU/Linux (Debian testing).  sed 4.1.5 doesn't.

Cheers,
Ralf

> --- orig/sed/utils.c
> +++ mod/sed/utils.c
> @@ -328,6 +328,15 @@ ck_fclose(stream)
>      {
>        do_ck_fclose (stdout);
>        do_ck_fclose (stderr);
> +
> +      /* When a standard utility reads a seekable input file and terminates
> +      without an error before it reaches end-of-file, the utility shall 
> ensure
> +      that the file offset in the open file description is properly 
> positioned
> +      just past the last byte processed by the utility.  */
> +
> +      fflush(stdin);
> +      fseek(stdin, 0, SEEK_CUR);
> +      fclose(stdin);
>      }
>  }
>  




reply via email to

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