in reply to dup2 socket descriptor using SSL

You can't do that as the SSL layer runs inside the Perl process and will not survive the exec call.

What you need is an SSL proxy that talks SSL in one side and clean data on the other.

Fortunately for you I had the same problem some time ago, and the solution is published on CPAN as IO::Socket::Forwarder:

# untested and error checks omitted!!! use IO::Socket::Forwarder; use Socket; use POSIX qw(_exit dup2); my $proxy_pid = fork; unless ($proxy_pid) { socketpair(my $sock_parent, my $sock_child, AF_UNIX, SOCK_STREAM, PF +_UNSPEC); my $sspid = fork; unless ($sspid) { my $fn = fileno $sock_child; $fn < 3 and die "bad fileno"; dup2($sock_child, 0); dup2(0, 1); dup2(0, 2); { exec "/bin/bash"; } _exit(1); } close $sock_child; forward_sockets($fd, $sock_parent); _exit(0); }