Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use warnings; use strict;
- use 5.012;
- use IPC::System::Simple qw(system);
- system( 'xterm', '-geometry', '80x25-5-5', '-bg', 'green', '&' );
- say "Hello";
- say "World";
- system("cmd &")
- $SIG{CHLD} = sub { wait };
- $SIG{CHLD} = 'IGNORE';
- unless ($pid = fork) {
- unless (fork) {
- exec "what you really wanna do";
- die "exec failed!";
- }
- exit 0;
- }
- waitpid($pid, 0);
- system('xterm -geometry 80x25-5-5 -bg green &');
- if (my $pid = fork) { #exits 0 = false for child process, at this point is brain split
- # parent ($pid is process id of child)
- #do something what you want, asynchronously with executed command
- waitpid($pid); #wait until child ends
- #if you don't want, don't wait. you process ends, then child process will be relinked
- #from your script to INIT process, and finally INIT will assume child finishing.
- #alternatively you can handle SIGCHLD signal in your script
- } else {
- # child
- exec('some_command arg1 arg2'); #or exec('some_command','arg1','arg2');
- #exit is not needed, because exec completly overwrites process content
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement