Re: bug in kernel

From: linux-os
Date: Mon Mar 14 2005 - 12:01:55 EST


On Mon, 14 Mar 2005, Evgeniy wrote:

Here is a simple program.

#include <stdio.h>
#include <errno.h>
main(){
int err;
err=read(0,NULL,6);
printf("%d %d\n",err,errno);
}

I think that it should be an error : Null pointer assignment, like in windows.
But in practise it is not so.

It is an error. It will wait <forever> until you enter the [Enter]
key (it's reading from STDIN_FILENO). Then it will return -1 which
means there was an error, the error code in errno is 14 (EFAULT)
or "bad address".

You can configure user-mode code to "seg-fault" upon receiving
such an error. It can print a nasty message and leave a worthless
core file in your directory.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/