Pete's Log: an important lesson

Entry #645, (Coding, Hacking, & CS stuff)
(posted when I was 22 years old.)

From time to time it is a good idea to do a "grep PWR: *.c *.h" because as it turns out, I leave myself valuable comments whenever I'm not sure if I'm doing the right thing. And turns out I left one of those comments for myself at the location that I figured out was causing the SIGTTIN when running ush in bcheck. The exact cause of what's causing the SIGTTIN when running bcheck turned out to be a stupid error. I assumed, stupidly, that the foreground process group of the controlling tty would be, at shell startup, the same as my shell's process id. In most cases this is true, since most shells will give forked children a new process group with pid = pgid and set that pgid to be the foreground process of the terminal. bcheck (and dbx, as it turns out) don't. They leave forked processes inside their process group. And thus my problems. So that's easy enough to fix now. And now that that is fixed, I've been able to determine that ush is memory leak free. Woohoo!

One other quick test: do I leak file descriptors? A very likely possibility. But turns out I don't! Woohoo!

The other big problem I was having with running ush inside ush not working has also been fixed. That turned out to be YARC (yet another race condition) that was easy enough to fix.

The latest, greatest problem: any multiple job, foreground pipeline in which the last command is a shell builtin. Turns out I really shouldn't be setting stdin for my shell to the output of some other command. It causes badness. But that's yet another easy fix.

Doh! Yet another problem. This time if I run ush inside bcheck, and then launch ush inside there again, the second ush will segfault. No es bueno. I don't have a clue as to why this is happening. There seem to be some weird things going on with LD_PRELOAD things that bcheck does, as well as with virtual memory... and somehow I've got a suspicion Dr Freeh won't have a test case to see if ush can run within ush within bcheck. So I'm not gonna worry about this anymore...

So having gotten rid of those problems (by either fixing them or ignoring them), and being unable to find any new ones, I am going to hesitantly call my shell done.