Here s a simplified version of my code:
- (IBAction)convert:(id)sender
{
/* these two lines are ignored */
[textbox setStringValue:@"converting"];
[convertButton setEnabled:NO];
pid_t pid;
if((pid=fork())==-1)
{
[log setStringValue:@"couldn t fork a new process."];
converting = 0;
[convertButton setEnabled:YES];
return;
}else if (pid==0)
{
//this is the child
sleep(2);
exit(0);
}else{
int status;
waitpid(pid,&status,0);
}
}
}
It s a pretty basic fork() call. The problem is, the two lines at the very top (marked with a comment) are ignored...they don t seem to execute until after the forked child exits. Why?
Edit: And what can I do to fix it?