Hello all, I currently have the following program which uses fork to create two child processes which exit normally and return back to the parents and give the following output:

child 2916 terminated normally with exit status=199
child 2917 terminated normally with exit status=200

However, I'm trying to induce a segmentation error by making the child write to a read-only segment of memory, which I tried to do right after the fork() command in the child section, which only made the program not give any output? I'm trying to alter the program to be able to handle segmentation faults so that it will print the following output:

child 2916 terminated by signal 11: Segmentation fault
child 2917 terminated by signal 11: Segmentation fault

What am I doing wrong? And what is the best way of going about setting up a sig handler? How about psignal() ?

Any help would be appreciated, thanks!

Code:
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>


#define N 2


pid_t Fork(void)
{
        pid_t pid;
        if ((pid = fork()) < 0)
            printf("Fork error");
        return pid;
}

int main()
{
        int status, i;
        pid_t pid;

        for (i = 0; i < N; i++)
            if ((pid = Fork()) == 0)   /* child */
                memset((char *)0x0, 42, 200);    
                /*should cause seg fault */

                exit(199+i);


        /* parent waits for all of its children to terminate */
        while ((pid = waitpid(-1, &status, 0)) > 0) {
            if (WIFEXITED(status))
            printf("child %d terminated normally with exit status=d\n",
                       pid, WEXITSTATUS(status));
            else
                printf("child %d terminated abnormally\n", pid);
        }
        if (errno != ECHILD)
   /*      unix_error("waitpid error"); */

        exit(0);