ajeet@perl has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks

I am using Perl on a Solaris Machine, I am getting core dump of my processes in /var/core, when i termintae my program using ctrl+c, Even When i register handler for INT,TERM,KILL signal. I have writtent following in my handler ....

################################################################# # # Name : sigTERMhandler # Input : None # Return : None # # Function of subroutine: # Handler for SIGTERM # ################################################################# sub sigTERMhandler { # # if debug is ON,log a debug statement if( defined $options{d} || $DEBUG eq "ON" ) { $log->print($filename.":".__LINE__.": Received TERM process ID + :: " . $$ . " Shutting Down Gracefully...\n"); } exit(0); }

Any pointer, about how to prevent my program to avoid core dumps..

Thanks in Advance

Replies are listed 'Best First'.
Re: Process Core dumps
by salva (Canon) on Apr 12, 2010 at 08:36 UTC
    Which version of Perl is installed on the Solaris box?

    Run perl -V and post here the output.

      Output of perl -v
      This is perl, v5.8.8 built for sun4-solaris Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge.
        is PERL_SIGNALS defined in your environment?

        And run perl -V again but this time with an uppercased V!

Re: Process Core dumps
by cdarke (Prior) on Apr 12, 2010 at 08:37 UTC
    Is ctrl+c generating a SIGINT? Check stty -a on your terminal.
      Yes, ctrl+c is generating INT

      output of stty -a

      speed 38400 baud; rows = 41; columns = 126; ypixels = 0; xpixels = 0; csdata ? eucw 1:0:0:0, scrw 1:0:0:0 intr = ^c; quit = ^\; erase = ^?; kill = ^u; eof = ^d; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^q; stop = ^s; susp = ^z; dsusp = ^y; rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v; -parenb -parodd cs8 -cstopb -hupcl cread -clocal -loblk -crtscts -crts +xoff -parext -ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iucl +c ixon -ixany -ixoff imaxbel isig icanon -xcase echo echoe echok -echonl -noflsh -tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel tab3
Re: Process Core dumps
by Marshall (Canon) on Apr 12, 2010 at 20:43 UTC
    I don't have access to a Solaris box right now. But of course one approach would be to disable process core dumps and then Perl or anything else won't generate one. Solaris Core Dumps

    I would suggest simplifying to the basics. I didn't see your statement that installed the handler. Try running this and see what happens.

    #!/usr/bin/perl -w use strict; $SIG{INT} = \&handler; while (1) { sleep(1); } sub handler { print "ctl-c entered\n"; exit(0); }
    I am on Windows now and there is some strangeness in how CTL-C is implemented (with a INT handler installed, it will not interrupt the sleep() function, e.g. with sleep(5), it might take 5 seconds for the CTL-C handler to be executed!).

    Try the above and see what happens. If you still get a core dump, take out the print statement and try again with just the "exit(0)" statement. Sometimes (sys dependent), you may not be able to do anything useful after a CTRL-C except exit. I suppose that it is possible that your debug logging statement itself may be causing the core dump depending upon what is going on when you hit CTL-C.