Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 about the Monastery: (5)
As of 2014-09-20 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (164 votes), past polls