Subject: Re: A little program I wrote that core dumps. Should it?
To: None <port-arm32@NetBSD.ORG>
From: Alexander Hayward <alexander.hayward@lady-margaret-hall.oxford.ac.uk>
List: port-arm32
Date: 06/16/1997 19:00:16
On Mon, 16 Jun 1997, Peter Naulls wrote:
> > void main(void) {
> > FILE *f;
> > f = fopen("/dev/lpt0");
> > while (!feof(f)) putchar(fgetc(f));
> > }
>
> > cause a core dump after a little while?
>
> You're not checking to see if f is void, which it will be
> if you can't open /dev/lpt0, so there ends up being a
> null pointer reference.
True, and that was the cause (I did have a "r", but I forgot about it when
I typed this in). I was just fooled by the fact that it took 16 seconds to
do it... I had expected to either fail immediately or block indefinitely.