The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IO::Pty::HalfDuplex::Ptyish - Base class for pty-using HalfDuplex backends

SYNOPSIS

    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;

DESCRIPTION

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:

$pty->shell(info_pipe => $status_fh, ctl_pipe => $control_fh, command => \@argv)

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.

AUTHOR

Stefan O'Rear, <stefanor@cox.net>

BUGS

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.

COPYRIGHT AND LICENSE

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.