http://qs321.pair.com?node_id=1138552


in reply to Re: Perl migration hp-ux -> Linux
in thread Perl migration hp-ux -> Linux

Well that's the issue, the perl program just stops there, no core file, nothing to go on. a sample program:
#! /usr/local/bin/perl use Oraperl; use DBI; use FileHandle; use rf; use IO::Socket; use IO::Handle;; use POSIX qw(setsid); open STDIN, '>/dev/null' or die "Can't read /dev/null: $!"; print "Step 1\n"; #open STDOUT, '>','/dev/null' or die "Can't write to $prout: $!"; open(STDOUT, '>','/dev/null') or die "Can't write to $prout: $!"; print "Step 2\n"; open STDERR, '>/dev/null' or die "Can't write to $prerr: $!"; #SIG{CHLD} = 'IGNORE'; defined(my $pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; #$SIG{CHLD} = 'DEFAULT'; #--------------------------- # Get Environment Variables #--------------------------- $logdir = $ENV{out}; $constr = $ENV{CAAO_CSTR}; $user = $ENV{CAAO_USU}; $pass = $ENV{CAAO_PWD}; print"RUN\n";
It only prints Step 1 But when the line is commented, it prints Step 1 Step 2 RUN

Replies are listed 'Best First'.
Re^3: Perl migration hp-ux -> Linux
by Corion (Patriarch) on Aug 14, 2015 at 10:12 UTC

    If you reopen STDOUT to /dev/null, where do you expect the output of print to go?

Re^3: Perl migration hp-ux -> Linux
by pme (Monsignor) on Aug 14, 2015 at 10:20 UTC
    This line
    open(STDOUT, '>','/dev/null') or die "Can't write to $prout: $!";
    redirects STDOUT to /dev/null therefore all 'print' is redirected into /dev/null.
Re^3: Perl migration hp-ux -> Linux
by aitap (Curate) on Aug 14, 2015 at 10:20 UTC

    If stepping through the program in Perl debugger doesn't help, try opening STDOUT/STDERR to some log file ("/tmp/$$.log", for example) or writing a __DIE__ signal handler:

    sub { return unless defined $^S; # bail out if it's a parser error open my $log, ">/tmp/crash@{[time]}_$$.log"; print $log @_; }