I may be wrong but what I feel is the pid_t data type within switch() is causing the error with -1. As negativity of the choice element is not correctly defined in some cases its better if you use an integer variable to hold the ForkPid value.
as
int pid;
.
.
pid=fork();
.
.
switch(pid)
{
.
.
}
This will satisfy your needs as the returned value of pid from a child process shall always come within the limits of signed integers.