Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: TCP Client not working

by oiskuu (Hermit)
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1059927]
help
Chatterbox?
[Corion]: Oh yay. Why do I test a migration with transaction code "T" when the real trades from the migration will come with P9N (which is excluded from the processing)?

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2017-09-26 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (296 votes). Check out past polls.

    Notices?