Why doesn't this simple two line program work ...
sramtrc at windy.dsir.govt.nz
sramtrc at windy.dsir.govt.nz
Fri Jan 4 11:00:50 AEST 1991
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 at albert.dsir.govt.nz
More information about the Comp.unix.aux
mailing list