I am trying to write on the /dev/simulator file. I have created this device by using:
- # mknod /dev/simulator c 60 0
- # chmod 666 /dev/simulator
- # ls -l /dev/simulator
- crw-rw-rw- 1 root root 60, 0 2012-05-22 19:22 /dev/simulator
I am trying to open this device and write something on it, but getting an error:
application: Simulator opening failed
which is defined by me in condition, but why am I not able to get into the device? Here is my code:
/*
* Some Other Code *
*/
static int simDev;
simDev = open("/dev/simulator", O_RDWR);
if(simDev<0) {
printf("application: Simulator opening failed.\n");
exit (1);
}
else
printf("Device opened successfully.");
signal(SIGIO, signal_handler);
pid_t pid;
pid = getpid();
write(simDev, &pid, 4);
/*
* Some Other Code *
*/
close(simDev);
Can anyone please help me correct my mistake?