Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: TCP Client not working

by oiskuu (Pilgrim)
on Oct 27, 2013 at 17:45 UTC ( #1059927=note: print w/ replies, xml ) Need Help??


in reply to TCP Client not working

If your intent is to start an interactive shell on the server, then you'll probably want to spawn it with a TTY (using IO::Pty).

my $pty = new IO::Pty; $pty->set_raw(); my $pid = fork // die; unless ($pid) { $pty->make_slave_controlling_terminal(); close STDIN; open STDIN, "+>&", $pty->slave; # ditto for STDOUT, ...; close $pty->slave; exit !exec @the_program; } close $pty->slave; event_loop_passing_data_between($pty, $socket)
To pass window size/ttype/etc., the Net::Telnet interface might be chosen. You've essentially reimplemented the telnetd.

OTOH, if you simply want to avoid signals from the child interrupting the server process, the following might be of use:

use POSIX; my $pid = fork(); if ( $pid == 0 ) { setsid(); close STDIN; close STDOUT; close STDERR; RunCommand( ... ); }
Child setsid() detaches it from the controlling tty.


Comment on Re: TCP Client not working
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1059927]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-09-16 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (155 votes), past polls