IO::Pty::HalfDuplex::Ptyish - Base class for pty-using HalfDuplex backends
package IO::Pty::HalfDuplex::PTrace; use base 'IO::Pty::HalfDuplex::Ptyish'; sub shell { my %args = @_; #start subprocess syswrite $args->{info_pipe}, pack("N", $pid); while(1) { # wait for subprocess to block if (subprocess died) { syswrite $args->{info_pipe}, "d" . pack("CC", $sig, $code); POSIX::_exit(); } syswrite $args->{info_pipe}, "r"; sysread $args->{ctl_pipe}, $_, 1; # continue subprocess } } 1;
IO::Pty::HalfDuplex::Ptyish is the base class for pty-using HalfDuplex backends. It implements the HalfDuplex methods by opening a pty and starting a slave process to control the child; this slave communicates with the main process using a pair of pipes. Subclasses must implement the shell() method, with the following specification:
IO::Pty::HalfDuplex::Ptyish
shell()
shell forks and starts the child process as if by exec(@argv). It then writes the PID of the child in pack "N" format to $status_fh, and enters an infinite loop in the parent. Each time the child stops waiting for input, the character "r" is written to $status_fd; the client process will request a restart by putting more data into the pty buffer and writing "s" to $control_fh. When the child exits, write a "d" to $status_fd, followed by the child's exit signal or 0 and exit code or 0, each in pack "C" format. The shell then calls _exit.
shell
exec(@argv)
pack "N"
pack "C"
Stefan O'Rear, <stefanor@cox.net>
<stefanor@cox.net>
No known bugs.
Please report any bugs through RT: email bug-io-halfduplex at rt.cpan.org, or browse http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IO-HalfDuplex.
bug-io-halfduplex at rt.cpan.org
Copyright 2008-2009 Stefan O'Rear.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install IO::Pty::HalfDuplex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Pty::HalfDuplex
CPAN shell
perl -MCPAN -e shell install IO::Pty::HalfDuplex
For more information on module installation, please visit the detailed CPAN module installation guide.