in reply to Emulating UNIX 'top' on AIX

Ok. So now I am able to fork, process the system calls and read characters using the parent.

My next problem is how to communicate an option change to the child. I was originally considering SIGHUP, but I had forgotten that it is primarily used where information is stored in a file.

I could fork for each sleep cycle, but that seems wasteful.

Or I could explicitly kill the child and respawn a new one with new options. Which, for some reason, seems like cheating.

Another option would be to use only a single process and determine a way to make any input to be a signal interrupt which would need to be processed (and I'm not sure this would work).

Any other ideas out there?

Replies are listed 'Best First'.
Re^2: Emulating UNIX 'top' on AIX
by 5mi11er (Deacon) on May 02, 2005 at 21:22 UTC
    You could
    • setup a communication pipe between the two processes and use a non-blocking select to determine if information is there to be read...
    • or use SIGHUP, regardless of what anyone thinks it's reserved for...
    • do the kill/respawn thing, but I think that's going to be widely regarded as an ugly option
    • I think a fork per sleep cycle is even worse than the above option.
    • Do the single process thing, with a non-blocking select to determine if there is input to read
    Personally, I believe the first or last options are the better options...

    -Scott