in reply to local scoped cwd

Just thought I'd point out that it is not always possible to return to the directory you were in... so depending on your requirements, you might be better off doing something like:

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. }