If I use fork () and exec (), can I run a .sh script in parallel with a perl script? [...] It looks like a script call to run in the background.
Yes. Fork and exec are actually the way shells run commands in the background.
Is there some kind of security that I can implement to know that the child process came out correctly too?
Yes, using waitpid () and looking at the return value stored in $?
As mentioned by @rohanpm, the perlipc page has many useful examples showing how to do this. Here is one of the most relevant where the signal handler is configured for SIGCHLD (which will be sent to the parent when the child is finished)
use POSIX ":sys_wait_h"; $SIG{CHLD} = sub { while ((my $child = waitpid(-1, WNOHANG)) > 0) { $Kid_Status{$child} = $?; } };
source share