this simple code is throwing segmentation fault at run time, Any help will be precious for me...
Code:#include <stdio.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdlib.h> #include <sys/types.h> main() { int shmWid, *written; shmWid = (IPC_PRIVATE, sizeof(int), 0777 | IPC_CREAT); if (fork() == 0) { written = (int *)shmat(shmWid, 0,0); sleep(1); } else { written = (int *)shmat(shmWid, 0,0); *written = 0; } wait(); }