PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Steven Cruz <steve at nextopia dot com>
Subject: Re: Problem with FORK in perl
Date: Jan 31 2001 6:52PM

 if ($child = fork)
        {
                print "the child is $child\n";
                print "the child count is ", $child_counter++,"\n";
        }
        elsif ($child == 0)
        {
                use POSIX qw(setsid);
                setsid()            or die "Can't start a new session:
$!";

I believe the setsid function should be able to help you with that. 





"Sabherwal, Balvinder K." wrote:
> 
> I have a perl script and I am trying to FORK child proccesses. I am getting
> the error as below. I get this error when I try to run the program in debug
> mode. if it is run normally, it just do nothing.
> 
> the code is also given below which dose the fork.
> 
> Any help will be greatly appriciated. This code runs perfect on HP-UX and
> has problems on AIX and SUN.
> 
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> ######### Forked, but do not know how to change a TTY. #########
>   Define $DB::fork_TTY
>        - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
>   The value of $DB::fork_TTY should be the name of TTY to use.
>   On UNIX-like systems one can get the name of a TTY for the given window
>   by typing tty, and disconnect the shell from TTY by sleep 1000000.
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> ######### Forked, but do not know how to change a TTY. #########
>   Define $DB::fork_TTY
>        - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
>   The value of $DB::fork_TTY should be the name of TTY to use.
>   On UNIX-like systems one can get the name of a TTY for the given window
>   by typing tty, and disconnect the shell from TTY by sleep 1000000.
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> ######### Forked, but do not know how to change a TTY. #########
>   Define $DB::fork_TTY
>        - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
>   The value of $DB::fork_TTY should be the name of TTY to use.
>   On UNIX-like systems one can get the name of a TTY for the given window
>   by typing tty, and disconnect the shell from TTY by sleep 1000000.
> 
> # Forking off all the child processes begins here
>     for ($i = 0; $i < $no_of_child; $i++) {
>         $ChildPID = fork;
>         if (! defined $ChildPID) {    # Error
>             $ErrCode = $E_FORK;
>             $ErrMsg  = "Error $Self->{ErrCode}, " . "Cannot fork all
> children.\n";
>             # Terminate all children
>             kill ('KILL', @ChildList);
>             foreach $ChildPID (@ChildList) {
>                 waitpid ($ChildPID, 0)
>             }
>             return 0;
>         } elsif ($ChildPID) {         # Parent
>         .....
>           } else { ........
>              }
>     }
> 
> Balvinder K. Sabherwal
> Corporate Technology
> Legg Mason
> 410.454.3649
> bksabherwal@leggmason.com
> 
> IMPORTANT:  The security of electronic mail  sent through the Internet
> is not guaranteed.  Legg Mason therefore recommends that you do not
> send confidential information to us via electronic mail, including social
> security numbers, account numbers, and personal identification numbers.
> 
> Delivery, and timely delivery, of electronic mail is also not
> guaranteed.  Legg Mason therefore recommends that you do not send time-sensitive
> or action-oriented messages to us via electronic mail, including
> authorization to  "buy" or "sell" a security or instructions to conduct any
> other financial transaction.  Such requests, orders or instructions will
> not be processed until Legg Mason can confirm your instructions or
> obtain appropriate written documentation where necessary.




"Sabherwal, Balvinder K." wrote:
> 
> I have a perl script and I am trying to FORK child proccesses. I am getting
> the error as below. I get this error when I try to run the program in debug
> mode. if it is run normally, it just do nothing.
> 
> the code is also given below which dose the fork.
> 
> Any help will be greatly appriciated. This code runs perfect on HP-UX and
> has problems on AIX and SUN.
> 
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> ######### Forked, but do not know how to change a TTY. #########
>   Define $DB::fork_TTY
>        - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
>   The value of $DB::fork_TTY should be the name of TTY to use.
>   On UNIX-like systems one can get the name of a TTY for the given window
>   by typing tty, and disconnect the shell from TTY by sleep 1000000.
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> ######### Forked, but do not know how to change a TTY. #########
>   Define $DB::fork_TTY
>        - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
>   The value of $DB::fork_TTY should be the name of TTY to use.
>   On UNIX-like systems one can get the name of a TTY for the given window
>   by typing tty, and disconnect the shell from TTY by sleep 1000000.
> Debugged program terminated.  Use q to quit or R to restart,
>   use O inhibit_exit to avoid stopping after program termination,
>   h q, h R or h O to get additional info.
> ######### Forked, but do not know how to change a TTY. #########
>   Define $DB::fork_TTY
>        - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
>   The value of $DB::fork_TTY should be the name of TTY to use.
>   On UNIX-like systems one can get the name of a TTY for the given window
>   by typing tty, and disconnect the shell from TTY by sleep 1000000.
> 
> # Forking off all the child processes begins here
>     for ($i = 0; $i < $no_of_child; $i++) {
>         $ChildPID = fork;
>         if (! defined $ChildPID) {    # Error
>             $ErrCode = $E_FORK;
>             $ErrMsg  = "Error $Self->{ErrCode}, " . "Cannot fork all
> children.\n";
>             # Terminate all children
>             kill ('KILL', @ChildList);
>             foreach $ChildPID (@ChildList) {
>                 waitpid ($ChildPID, 0)
>             }
>             return 0;
>         } elsif ($ChildPID) {         # Parent
>         .....
>           } else { ........
>              }
>     }
> 
> Balvinder K. Sabherwal
> Corporate Technology
> Legg Mason
> 410.454.3649
> bksabherwal@leggmason.com
> 
> IMPORTANT:  The security of electronic mail  sent through the Internet
> is not guaranteed.  Legg Mason therefore recommends that you do not
> send confidential information to us via electronic mail, including social
> security numbers, account numbers, and personal identification numbers.
> 
> Delivery, and timely delivery, of electronic mail is also not
> guaranteed.  Legg Mason therefore recommends that you do not send time-sensitive
> or action-oriented messages to us via electronic mail, including
> authorization to  "buy" or "sell" a security or instructions to conduct any
> other financial transaction.  Such requests, orders or instructions will
> not be processed until Legg Mason can confirm your instructions or
> obtain appropriate written documentation where necessary.