Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!comp.vuw.ac.nz!windy!sramtrc From: sramtrc@windy.dsir.govt.nz Newsgroups: comp.unix.aux Subject: Why doesn't this simple two line program work ... Keywords: write stdout trap 0 Message-ID: <18794.2783c5b2@windy.dsir.govt.nz> Date: 4 Jan 91 00:00:50 GMT Reply-To: sramtrc@albert.dsir.govt.nz Organization: DSIR, Wellington, New Zealand Lines: 34 Here is a simple program that works fine when the value 20 is replaced by a smaller integer. But when 20 or more lines are printed the program does not do anything - it just hangs forever. main() { register int j; for (j = 0; j < 20; j++) write(1, "Why doesnt this program work for 20?\n", 37); } Pretty simple program huh? It is shorter than the commands to compile and link it. It is linked to run under A/UX in the MacOS environment (naturally it runs fine as a pure UNIX program). cc -I/usr/include/mac -B /usr/lib/big/ -O -DAUX -c main.c ld /usr/lib/maccrt0.o /lib/crt2.o main.o /usr/lib/low.o -lmac_s -lld -lmr \ -lc_s /lib/crtn.o /usr/lib/low.ld I have played with this one for days and I can't figure it out. MacsBug shows that it hangs at the trap 0 that is used for the write system call. One way to get it to work for some cases is to pipe the output somewhere eg a.out | cat, but more complicated programs print nothing when this method is used (even though they don't hang). I have played with all sorts of initialisation stuff like noEvents = 1, InitWindows() InitGraf() and stuff like that but to no avail. What am I doing wrong? Cheers, Tony Cooper sramtrc@albert.dsir.govt.nz