grep hang - grep xxxx * - Unix

This is a discussion on grep hang - grep xxxx * - Unix ; I use grep, it work just fine on all of my systems sun Solaris, but on one particully system it alwyas hang. The system I built as other system, there is no different from other systems I have. It seems ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: grep hang - grep xxxx *

  1. grep hang - grep xxxx *

    I use grep, it work just fine on all of my systems sun Solaris, but on
    one particully system it alwyas hang. The system I built as other
    system, there is no different from other systems I have.
    It seems that the grep command grep the first file then hang. It could
    not grep the string for
    next file. The command I use as below:

    grep xxx *

    grep all of file in the same directory.

    Please shed a light.
    tks


  2. Re: grep hang - grep xxxx *

    blackdog wrote:
    >
    > I use grep, it work just fine on all of my systems sun Solaris, but on
    > one particully system it alwyas hang. The system I built as other
    > system, there is no different from other systems I have.
    > It seems that the grep command grep the first file then hang. It could
    > not grep the string for
    > next file. The command I use as below:
    >
    > grep xxx *
    >
    > grep all of file in the same directory.


    What directory are you in and what types of files are there?
    If you're in /dev there are plenty of files that will take a very
    long time before they run out of data like the device file of a
    large filesystem, and others like tty* that will wait until
    someone hooks up a terminal and types ^D.

    If you're in /var/spool/lp you might have a FIFO file that
    might never have an end up file.

    If you're NFS mounted maybe the server went down.
    Many other possibilities that can't be guessed without context.


  3. Re: grep hang - grep xxxx *


    Doug Freyburger wrote:
    > blackdog wrote:
    > >
    > > I use grep, it work just fine on all of my systems sun Solaris, but on
    > > one particully system it alwyas hang. The system I built as other
    > > system, there is no different from other systems I have.
    > > It seems that the grep command grep the first file then hang. It could
    > > not grep the string for
    > > next file. The command I use as below:
    > >
    > > grep xxx *
    > >
    > > grep all of file in the same directory.

    >
    > What directory are you in and what types of files are there?


    They all are plan text files, and it is not in /dev directory.
    Just regular directory data files. And the files is not large ether.
    I can grep easily on other system in the same directory.

    > If you're in /dev there are plenty of files that will take a very
    > long time before they run out of data like the device file of a
    > large filesystem, and others like tty* that will wait until
    > someone hooks up a terminal and types ^D.

    Would you please elaborate a littile more about tty* vs. grep hang and
    ^D
    >
    > If you're in /var/spool/lp you might have a FIFO file that
    > might never have an end up file.
    >
    > If you're NFS mounted maybe the server went down.
    > Many other possibilities that can't be guessed without context.



  4. Re: grep hang - grep xxxx *

    blackdog wrote:
    > Doug Freyburger wrote:
    > > blackdog wrote:

    >
    > > If you're in /dev there are plenty of files that will take a very
    > > long time before they run out of data like the device file of a
    > > large filesystem, and others like tty* that will wait until
    > > someone hooks up a terminal and types ^D.

    >
    > Would you please elaborate a littile more about tty* vs. grep
    > hang and ^D


    Device files named tty* and pty* are software emulations of
    terminal lines or serial lines. What's an end-of-file on a serial
    line? Control-D. So if you open a serial line for read and
    keep reading until the end-of-file you are going to hang until
    someone on the far end supplied a control-D or a hang-up
    signal or whatever.

    The same will apply to named tty*, pty*, named pipes,
    fifos and likely a few other types of file.

    Think of "tail -f". It reads from a regular file and waits rather
    than exitting when it hits the end of the buffered data. On
    a serial line or a software emulation of a serial line, it's
    still just a regular old file as far as fopen() is concerned so
    an fread() will wait until it completes.


  5. Re: grep hang - grep xxxx *


    Doug Freyburger wrote:
    > blackdog wrote:
    > > Doug Freyburger wrote:
    > > > blackdog wrote:

    > >
    > > > If you're in /dev there are plenty of files that will take a very
    > > > long time before they run out of data like the device file of a
    > > > large filesystem, and others like tty* that will wait until
    > > > someone hooks up a terminal and types ^D.

    > >
    > > Would you please elaborate a littile more about tty* vs. grep
    > > hang and ^D

    >
    > Device files named tty* and pty* are software emulations of
    > terminal lines or serial lines. What's an end-of-file on a serial
    > line? Control-D. So if you open a serial line for read and
    > keep reading until the end-of-file you are going to hang until
    > someone on the far end supplied a control-D or a hang-up
    > signal or whatever.
    >
    > The same will apply to named tty*, pty*, named pipes,
    > fifos and likely a few other types of file.
    >
    > Think of "tail -f". It reads from a regular file and waits rather
    > than exitting when it hits the end of the buffered data. On
    > a serial line or a software emulation of a serial line, it's
    > still just a regular old file as far as fopen() is concerned so
    > an fread() will wait until it completes.


    I use grep on command line. Thanks for all of explanation, I still
    don't know how to resolve the problem.


  6. Re: grep hang - grep xxxx *

    "blackdog" writes:

    >>> grep xxx *


    >>> grep all of file in the same directory.


    >> What directory are you in and what types of files are there?


    > They all are plan text files, and it is not in /dev directory.


    Are there any symlinks pointing off-filesystem?

    - Tim Skirvin (tskirvin@killfile.org)
    --
    http://www.killfile.org/~tskirvin/ Skirv's Homepage < <*>
    http://www.killfile.org/~tskirvin/friends/ Skirv's Friends

  7. Re: grep hang - grep xxxx *

    blackdog wrote:
    >
    > I use grep on command line. Thanks for all of explanation, I still
    > don't know how to resolve the problem.
    >


    either run grep with truss or run grep without truss and truss it as
    soon as it hangs. Once you have the filedescriptor causing the hang run
    pfiles on the pid of grep to find out which file is the offender.

    E.g.
    truss grep xxx *

    or

    grep xxx *
    ^Z
    bg
    pfiles -p `pgrep grep`
    truss -p `pgrep grep`

    HTH,
    Tom

  8. Re: grep hang - grep xxxx *

    On 23 May 2006 09:55:06 -0700, blackdog wrote:
    > I use grep, it work just fine on all of my systems sun Solaris, but on
    > one particully system it alwyas hang. The system I built as other
    > system, there is no different from other systems I have.
    > It seems that the grep command grep the first file then hang. It could
    > not grep the string for
    > next file. The command I use as below:
    >
    > grep xxx *
    >
    > grep all of file in the same directory.
    >
    > Please shed a light.

    [...]

    There may exist a file called "-" in the current directory. For
    some grep implementations, "-" means stdin, so grep will look
    for xxx on its standard input instead of from the file called
    "-".

    In anycase, you should always mark the end of options, as some
    files may as well be called "-F" or "-x"...

    grep xxx -- *

    or

    grep xxx ./*

    --
    Stephane

+ Reply to Thread