you should use vfork() instead of fork() and _exit() instead of kill().
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
int main (int argc, char *argv[]) {
int a = 0;
int pid;
pid = vfork();
if (pid == 0){
a++;
_exit(EXIT_SUCCESS);
} else if (pid > 0) {
printf("%d\n", a);
} else {
fprintf(stderr, "can't fork, error %d\n", errno);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
however, according to the
wikipedia entry on fork(): "on some systems, vfork() is the same as fork()."