if (fork()) { wait; } else { chdir ("/trap"); # code here - note: you will need to use IPC or some # other mechanism to get results back to the parent # process. }