in reply to Running a new Perl program
You can run external programs with your choice of system, fork, open, backticks, or exec. For what I think you want, a combination of fork and exec sounds right.
fork sets up a child process which then exec's the external program. Similar code can be wrapped up in a sub which acts as your Tk button handler.{ my @prog = ('/path/to/program', @opts, @args); my $pid = fork(); defined $pid or warn "Could not launch @prog" and last; last if $pid; # Parent # adjust child environment here, if desired exec @prog; }
Update: You should also make arrangements to prevent the child from going zombie. That can be done by setting up a $SIG{CHLD} handler, or with wait/waitpid. In an event-driven environment, and with the run of the child indeterminate, the SIGCHLD handler 'IGNORE' is probably best if that is usable on your platform.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Running a new Perl program
by pbeckingham (Parson) on May 16, 2004 at 23:28 UTC |