Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Apr 1995 18:59:52 -0500 (CDT)
From:      Peter da Silva <peter@bonkers.taronga.com>
To:        rpt@miles.sso.loral.com (Richard Toren)
Cc:        hackers@FreeBSD.org
Subject:   Re: aspfilter & stdin
Message-ID:  <199504162359.SAA02555@bonkers.taronga.com>
In-Reply-To: <Pine.SUN.3.91.950416174558.11362A-100000@miles> from "Richard Toren" at Apr 16, 95 05:54:29 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> I have modified the 'rewindstdin.c' as:

>    #include <stdio.h>
>    #include <unistd.h>

>    main()
>    {
>      return lseek(0,0L,SEEK_SET) < 0; 
>    }

> Giving the following results:
>    <src/rewind-stdin># make
>    cc -s -O -o rewindstdin rewindstdin.c
>    <src/rewind-stdin># cat rewindstdin.c | (file -; ./rewindstdin ;file -) 
>    standard input:              c program text
>    standard input:              empty

You can't rewind a pipe.

Period.

Try "(file - ; ./rewindstdin ; file -)  < rewindstdin.c".

> ?? why the '< 0' of the return code??

RETURN VALUES
     Upon successful completion, lseek() returns the resulting offset location
     as measured in bytes from the beginning of the file.  Otherwise, a value
     of -1 is returned and errno is set to indicate the error.

It should be "return lseek(0,0L,SEEK_SET) == -1;"

I don't believe that any other nonzero result is possible in this case, but
it's always better to check for the documented return value.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199504162359.SAA02555>