13 Jul 2000 crackmonkey   » (Master)

Seth just found a bug in nwall the other night. It turns out that the ttymsg code I used was written under the assumption that the process using it would exit quickly, letting the fork()ed I/O processes get cleaned up by init.

That means there was no wait() anywhere! Since the ttymsg() function used by wall, write, and talkd forks off a child whenever writing to a tty would block, it was creating a zombie process every time we typed in a line! These zombies built up to the point where nobody could fork off any new processes. Exiting nwall orphaned them, letting init do a collossal clean-up job.

Seth suggested that I use wait3 or wait4, but I wanted to be all warm and fuzzy and POSIX-compliant, so I suggested waitpid(). Seth came up with the call before I could, so the ttymsg code in nwall now contains while(waitpid(0, NULL, WNOHANG)) ; in the parent section.

Of course, the thing I don't understand is why this was never caught, since the write program could potentially suffer the same problem.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!