Jeff Abrahamson on Wed, 6 Jun 2001 11:50:07 -0400


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

Re: file system shenanigans (was: Re: [PLUG] ELF Init section)


On Wed, Jun 06, 2001 at 09:39:55AM -0400, Bill Jonas wrote:
> On Wed, Jun 06, 2001 at 06:19:37AM -0400, Jeff Abrahamson wrote:
> > On Tue, Jun 05, 2001 at 08:41:26PM +0000, qumak wrote:
> > > anyone know exactly what that is?  would i be safe to assume that it means 
> > > EOF?
> > 
> > 0xA == '\n' is the LF that echo emits.
> 
> The kernel itself returns EOF (^D on UNIX) when an attempt is made to
> read the 6th block.

I have to nit-pick. The kernel does no such thing.

The shell interprets control-D as a keystroke to mean end of input. It
isn't even the character, just the character coming from a
terminal. For example, try the following (which I just did):

    Make a file (with emacs, e.g.) whose contents are

        abcd^Defghi

    (the ^D is a control-D embedded in the file)

    If the file is called foo, then

    $ cat foo > bar
    $ wc -c foo bar
         11 foo
         11 bar
         22 total
    $

    So, you see, the ^D in the input stream when not attached to a
    terminal doesn't matter.


    Now, if you are doing C programming, you'll recall that you get
    EOF on reading end of file. But that's why getc returns an int
    instead of a char: EOF == -1, a value that is safely outside the
    range of char.

This is a nit-pick, but rather important if you actually ever program
something, even at the level of writing a pipe. You *can* pipe binary
input through a pipe without worrying what's in that input (assuming
the program at the other end is ok with it).

    cat /usr/bin/emacs | strings | grep oatmeal

is just fine.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>



______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug