in reply to Re: Emulating UNIX 'top' on AIX
in thread Emulating UNIX 'top' on AIX

Well, I got around the blocking issue. I used waitpid $pid, WNOHANG and I can now read in from STDIN.

The next issue is to read character by character instead of line by line. Is there any pure Perl way to do this?

Replies are listed 'Best First'.
Re^3: Emulating UNIX 'top' on AIX
by Transient (Hermit) on May 02, 2005 at 16:09 UTC
    Ok, found some stuff about getc from the docs... using that seems to work!

    I'll post the code at the end for critique and future use.
Re^3: Emulating UNIX 'top' on AIX
by ikegami (Patriarch) on May 02, 2005 at 16:12 UTC

    No. <FILE>, getc, read and sysread all block until a newline is read (even if they only return one character at a time). That's why I mentioned Term::ReadKey.

    Well, maybe you can do something with PerlIO. I don't know anything about that.

      the Perl getc docs have references to system calls using stty icanon which seem to emulate reading character by character. While not the solution I would most like to use, it does serve its purpose :)