AFAICT wait() can only be used on child processes.
Apart from that, you should have included the proper header files (unistd.h, sys/types.h and sys/wait.h) and used the proper type for PID's (not 'int' but 'pid_t').
Then the compiler would have complained with an error telling you there was something wrong with the first argument of wait(). You could then have looked up the man page of wait(2) and see that you used wait() the wrong way.
wait() can be called in two ways:
Code:
pid_t wait(int *status);
pid_t waitpid(pid_t pid, int *status, int options);
So, if you call wait() with one argument, it needs to be a pointer-to-int (then wait() will write the status to the int). Not a pid_t and not an int.
If want to call wait() with a PID (pid_t type) you need to give 3 arguments.
And also the man page says it assumes to be waiting for child processes only.