Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Perl forking acting wierd

Expand Messages
  • James Washer
    Was LOG open? What do you mean it is unable to call other functions? - jim
    Message 1 of 8 , Jan 26, 2010
    • 0 Attachment
      Was LOG open?
      What do you mean it is unable to call other functions?
      - jim

      On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:
      > Hi All,
      >
      > I have a subroutine to create a daemon, subroutine is pasted below.
      >
      > ub Daemonize() {
      >
      > my $pid;
      > $pid=fork();
      > if(! defined($pid)){
      > #Forking Failed, we exit at this point
      > die("forking failed\n");
      > exit(1);
      > }
      > if ($pid>0) {
      > print LOG "Forking Success. Child PID: $pid \n";
      > exit();
      > }
      >
      > $|=1;
      >
      > print LOG "Child Process Executing... \n";
      > setsid();
      > chdir('/');
      > umask(0);
      >
      > close(STDIN);
      > close(STDOUT);
      > close(STDERR);
      > }
      >
      >
      > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.
      >
      > Can anyone please help me ?.
      >
      > Shammi
      >
      >
      >
      >
      >
      > ------------------------------------
      >
      > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
      >
      >
      >
    • Shameem Ahamed
      LOG was opened before calling the daemon function in the global scope. This is the entire program. I am calling other function after calling daemon , which
      Message 2 of 8 , Jan 26, 2010
      • 0 Attachment
        LOG was opened before calling the daemon function in the global scope.

        This is the entire program.
        I am calling other function after calling daemon , which should be running in child process.


        open(LOG,">> $LOGFILE") || die("Unable to create Log file $LOGFILE : $! \n Please run as SUPER user");

        &readConfigXML($config_file);
        &Daemonize();

        while(1)
        {

        &Slow_Query_Kill();
        sleep($slowtime)
        }

        close(LOG);


        --- On Wed, 1/27/10, James Washer <washergrp@...> wrote:

        From: James Washer <washergrp@...>
        Subject: Re: [PBML] Perl forking acting wierd
        To: perl-beginner@yahoogroups.com
        Date: Wednesday, January 27, 2010, 12:02 AM







         









        Was LOG open?

        What do you mean it is unable to call other functions?

        - jim



        On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:

        > Hi All,

        >

        > I have a subroutine to create a daemon, subroutine is pasted below.

        >

        > ub Daemonize() {

        >

        > my $pid;

        > $pid=fork();

        > if(! defined($pid) ){

        > #Forking Failed, we exit at this point

        > die("forking failed\n");

        > exit(1);

        > }

        > if ($pid>0) {

        > print LOG "Forking Success. Child PID: $pid \n";

        > exit();

        > }

        >

        > $|=1;

        >

        > print LOG "Child Process Executing... \n";

        > setsid();

        > chdir('/');

        > umask(0);

        >

        > close(STDIN) ;

        > close(STDOUT) ;

        > close(STDERR) ;

        > }

        >

        >

        > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.

        >

        > Can anyone please help me ?.

        >

        > Shammi

        >

        >

        >

        >

        >

        > ------------ --------- --------- ------

        >

        > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links

        >

        >

        >

























        [Non-text portions of this message have been removed]
      • James Washer
        And what did the problem do to lead you to think that it couldn t call functions.
        Message 3 of 8 , Jan 26, 2010
        • 0 Attachment
          And what did the problem do to lead you to think that it couldn't call
          functions.
          On Wed, 2010-01-27 at 00:17 +0530, Shameem Ahamed wrote:
          > LOG was opened before calling the daemon function in the global scope.
          >
          > This is the entire program.
          > I am calling other function after calling daemon , which should be running in child process.
          >
          >
          > open(LOG,">> $LOGFILE") || die("Unable to create Log file $LOGFILE : $! \n Please run as SUPER user");
          >
          > &readConfigXML($config_file);
          > &Daemonize();
          >
          > while(1)
          > {
          >
          > &Slow_Query_Kill();
          > sleep($slowtime)
          > }
          >
          > close(LOG);
          >
          >
          > --- On Wed, 1/27/10, James Washer <washergrp@...> wrote:
          >
          > From: James Washer <washergrp@...>
          > Subject: Re: [PBML] Perl forking acting wierd
          > To: perl-beginner@yahoogroups.com
          > Date: Wednesday, January 27, 2010, 12:02 AM
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > Was LOG open?
          >
          > What do you mean it is unable to call other functions?
          >
          > - jim
          >
          >
          >
          > On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:
          >
          > > Hi All,
          >
          > >
          >
          > > I have a subroutine to create a daemon, subroutine is pasted below.
          >
          > >
          >
          > > ub Daemonize() {
          >
          > >
          >
          > > my $pid;
          >
          > > $pid=fork();
          >
          > > if(! defined($pid) ){
          >
          > > #Forking Failed, we exit at this point
          >
          > > die("forking failed\n");
          >
          > > exit(1);
          >
          > > }
          >
          > > if ($pid>0) {
          >
          > > print LOG "Forking Success. Child PID: $pid \n";
          >
          > > exit();
          >
          > > }
          >
          > >
          >
          > > $|=1;
          >
          > >
          >
          > > print LOG "Child Process Executing... \n";
          >
          > > setsid();
          >
          > > chdir('/');
          >
          > > umask(0);
          >
          > >
          >
          > > close(STDIN) ;
          >
          > > close(STDOUT) ;
          >
          > > close(STDERR) ;
          >
          > > }
          >
          > >
          >
          > >
          >
          > > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.
          >
          > >
          >
          > > Can anyone please help me ?.
          >
          > >
          >
          > > Shammi
          >
          > >
          >
          > >
          >
          > >
          >
          > >
          >
          > >
          >
          > > ------------ --------- --------- ------
          >
          > >
          >
          > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links
          >
          > >
          >
          > >
          >
          > >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >
          > ------------------------------------
          >
          > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
          >
          >
          >
        • Shameem Ahamed
          As you can see in the code, i am calling the function Slow_Query_Kill in the child process. This function is not getting executed. My logic is, create a child
          Message 4 of 8 , Jan 26, 2010
          • 0 Attachment
            As you can see in the code, i am calling the function Slow_Query_Kill in the child process.

            This function is not getting executed.

            My logic is, create a child process, exit the parent, make child the session leader and run the function Sleep_Query_Kill in the child indefinitely.


            Regards,
            Shameem

            --- On Wed, 1/27/10, James Washer <washergrp@...> wrote:

            From: James Washer <washergrp@...>
            Subject: Re: [PBML] Perl forking acting wierd
            To: perl-beginner@yahoogroups.com
            Date: Wednesday, January 27, 2010, 2:19 AM







             









            And what did the problem do to lead you to think that it couldn't call

            functions.

            On Wed, 2010-01-27 at 00:17 +0530, Shameem Ahamed wrote:

            > LOG was opened before calling the daemon function in the global scope.

            >

            > This is the entire program.

            > I am calling other function after calling daemon , which should be running in child process.

            >

            >

            > open(LOG,">> $LOGFILE") || die("Unable to create Log file $LOGFILE : $! \n Please run as SUPER user");

            >

            > &readConfigXML( $config_file) ;

            > &Daemonize() ;

            >

            > while(1)

            > {

            >

            > &Slow_Query_ Kill();

            > sleep($slowtime)

            > }

            >

            > close(LOG);

            >

            >

            > --- On Wed, 1/27/10, James Washer <washergrp@trlp. com> wrote:

            >

            > From: James Washer <washergrp@trlp. com>

            > Subject: Re: [PBML] Perl forking acting wierd

            > To: perl-beginner@ yahoogroups. com

            > Date: Wednesday, January 27, 2010, 12:02 AM

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            > Was LOG open?

            >

            > What do you mean it is unable to call other functions?

            >

            > - jim

            >

            >

            >

            > On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:

            >

            > > Hi All,

            >

            > >

            >

            > > I have a subroutine to create a daemon, subroutine is pasted below.

            >

            > >

            >

            > > ub Daemonize() {

            >

            > >

            >

            > > my $pid;

            >

            > > $pid=fork();

            >

            > > if(! defined($pid) ){

            >

            > > #Forking Failed, we exit at this point

            >

            > > die("forking failed\n");

            >

            > > exit(1);

            >

            > > }

            >

            > > if ($pid>0) {

            >

            > > print LOG "Forking Success. Child PID: $pid \n";

            >

            > > exit();

            >

            > > }

            >

            > >

            >

            > > $|=1;

            >

            > >

            >

            > > print LOG "Child Process Executing... \n";

            >

            > > setsid();

            >

            > > chdir('/');

            >

            > > umask(0);

            >

            > >

            >

            > > close(STDIN) ;

            >

            > > close(STDOUT) ;

            >

            > > close(STDERR) ;

            >

            > > }

            >

            > >

            >

            > >

            >

            > > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.

            >

            > >

            >

            > > Can anyone please help me ?.

            >

            > >

            >

            > > Shammi

            >

            > >

            >

            > >

            >

            > >

            >

            > >

            >

            > >

            >

            > > ------------ --------- --------- ------

            >

            > >

            >

            > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links

            >

            > >

            >

            > >

            >

            > >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            >

            > [Non-text portions of this message have been removed]

            >

            >

            >

            > ------------ --------- --------- ------

            >

            > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links

            >

            >

            >

























            [Non-text portions of this message have been removed]
          • James Washer
            Once again.. HOW DO YOU KNOW IT IS NOT GETTING EXECUTED? Sorry for the caps, but it s been a trial getting information from you. I still don t know how you
            Message 5 of 8 , Jan 27, 2010
            • 0 Attachment
              Once again.. HOW DO YOU KNOW IT IS NOT GETTING EXECUTED?
              Sorry for the caps, but it's been a trial getting information from you.
              I still don't know how you know it's not getting executed.. but, just
              for kicks.. put a die in your sub and see if it dies.

              - jim

              On Wed, 2010-01-27 at 13:19 +0530, Shameem Ahamed wrote:
              > As you can see in the code, i am calling the function Slow_Query_Kill in the child process.
              >
              > This function is not getting executed.
              >
              > My logic is, create a child process, exit the parent, make child the session leader and run the function Sleep_Query_Kill in the child indefinitely.
              >
              >
              > Regards,
              > Shameem
              >
              > --- On Wed, 1/27/10, James Washer <washergrp@...> wrote:
              >
              > From: James Washer <washergrp@...>
              > Subject: Re: [PBML] Perl forking acting wierd
              > To: perl-beginner@yahoogroups.com
              > Date: Wednesday, January 27, 2010, 2:19 AM
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              > And what did the problem do to lead you to think that it couldn't call
              >
              > functions.
              >
              > On Wed, 2010-01-27 at 00:17 +0530, Shameem Ahamed wrote:
              >
              > > LOG was opened before calling the daemon function in the global scope.
              >
              > >
              >
              > > This is the entire program.
              >
              > > I am calling other function after calling daemon , which should be running in child process.
              >
              > >
              >
              > >
              >
              > > open(LOG,">> $LOGFILE") || die("Unable to create Log file $LOGFILE : $! \n Please run as SUPER user");
              >
              > >
              >
              > > &readConfigXML( $config_file) ;
              >
              > > &Daemonize() ;
              >
              > >
              >
              > > while(1)
              >
              > > {
              >
              > >
              >
              > > &Slow_Query_ Kill();
              >
              > > sleep($slowtime)
              >
              > > }
              >
              > >
              >
              > > close(LOG);
              >
              > >
              >
              > >
              >
              > > --- On Wed, 1/27/10, James Washer <washergrp@trlp. com> wrote:
              >
              > >
              >
              > > From: James Washer <washergrp@trlp. com>
              >
              > > Subject: Re: [PBML] Perl forking acting wierd
              >
              > > To: perl-beginner@ yahoogroups. com
              >
              > > Date: Wednesday, January 27, 2010, 12:02 AM
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > > Was LOG open?
              >
              > >
              >
              > > What do you mean it is unable to call other functions?
              >
              > >
              >
              > > - jim
              >
              > >
              >
              > >
              >
              > >
              >
              > > On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:
              >
              > >
              >
              > > > Hi All,
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > I have a subroutine to create a daemon, subroutine is pasted below.
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > ub Daemonize() {
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > my $pid;
              >
              > >
              >
              > > > $pid=fork();
              >
              > >
              >
              > > > if(! defined($pid) ){
              >
              > >
              >
              > > > #Forking Failed, we exit at this point
              >
              > >
              >
              > > > die("forking failed\n");
              >
              > >
              >
              > > > exit(1);
              >
              > >
              >
              > > > }
              >
              > >
              >
              > > > if ($pid>0) {
              >
              > >
              >
              > > > print LOG "Forking Success. Child PID: $pid \n";
              >
              > >
              >
              > > > exit();
              >
              > >
              >
              > > > }
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > $|=1;
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > print LOG "Child Process Executing... \n";
              >
              > >
              >
              > > > setsid();
              >
              > >
              >
              > > > chdir('/');
              >
              > >
              >
              > > > umask(0);
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > close(STDIN) ;
              >
              > >
              >
              > > > close(STDOUT) ;
              >
              > >
              >
              > > > close(STDERR) ;
              >
              > >
              >
              > > > }
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > Can anyone please help me ?.
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > Shammi
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > ------------ --------- --------- ------
              >
              > >
              >
              > > >
              >
              > >
              >
              > > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > >
              >
              > > [Non-text portions of this message have been removed]
              >
              > >
              >
              > >
              >
              > >
              >
              > > ------------ --------- --------- ------
              >
              > >
              >
              > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links
              >
              > >
              >
              > >
              >
              > >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
              >
              >
              > ------------------------------------
              >
              > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
              >
              >
              >
            • Shameem Ahamed
              Hello James. How i know ?. Because in the Slow query kill function, i am killing all the slow queries. and it is not happening.  I can see the child process
              Message 6 of 8 , Jan 27, 2010
              • 0 Attachment
                Hello James.

                How i know ?. Because in the Slow query kill function, i am killing all the slow queries. and it is not happening.  I can see the child process running , when i try ps.

                But it is not doing the tasks. I am really confused.


                Shammi



                --- On Wed, 1/27/10, James Washer <washergrp@...> wrote:

                From: James Washer <washergrp@...>
                Subject: Re: [PBML] Perl forking acting wierd
                To: perl-beginner@yahoogroups.com
                Date: Wednesday, January 27, 2010, 1:43 PM







                 









                Once again.. HOW DO YOU KNOW IT IS NOT GETTING EXECUTED?

                Sorry for the caps, but it's been a trial getting information from you.

                I still don't know how you know it's not getting executed.. but, just

                for kicks.. put a die in your sub and see if it dies.



                - jim



                On Wed, 2010-01-27 at 13:19 +0530, Shameem Ahamed wrote:

                > As you can see in the code, i am calling the function Slow_Query_Kill in the child process.

                >

                > This function is not getting executed.

                >

                > My logic is, create a child process, exit the parent, make child the session leader and run the function Sleep_Query_ Kill in the child indefinitely.

                >

                >

                > Regards,

                > Shameem

                >

                > --- On Wed, 1/27/10, James Washer <washergrp@trlp. com> wrote:

                >

                > From: James Washer <washergrp@trlp. com>

                > Subject: Re: [PBML] Perl forking acting wierd

                > To: perl-beginner@ yahoogroups. com

                > Date: Wednesday, January 27, 2010, 2:19 AM

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                > And what did the problem do to lead you to think that it couldn't call

                >

                > functions.

                >

                > On Wed, 2010-01-27 at 00:17 +0530, Shameem Ahamed wrote:

                >

                > > LOG was opened before calling the daemon function in the global scope.

                >

                > >

                >

                > > This is the entire program.

                >

                > > I am calling other function after calling daemon , which should be running in child process.

                >

                > >

                >

                > >

                >

                > > open(LOG,">> $LOGFILE") || die("Unable to create Log file $LOGFILE : $! \n Please run as SUPER user");

                >

                > >

                >

                > > &readConfigXML( $config_file) ;

                >

                > > &Daemonize() ;

                >

                > >

                >

                > > while(1)

                >

                > > {

                >

                > >

                >

                > > &Slow_Query_ Kill();

                >

                > > sleep($slowtime)

                >

                > > }

                >

                > >

                >

                > > close(LOG);

                >

                > >

                >

                > >

                >

                > > --- On Wed, 1/27/10, James Washer <washergrp@trlp. com> wrote:

                >

                > >

                >

                > > From: James Washer <washergrp@trlp. com>

                >

                > > Subject: Re: [PBML] Perl forking acting wierd

                >

                > > To: perl-beginner@ yahoogroups. com

                >

                > > Date: Wednesday, January 27, 2010, 12:02 AM

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > > Was LOG open?

                >

                > >

                >

                > > What do you mean it is unable to call other functions?

                >

                > >

                >

                > > - jim

                >

                > >

                >

                > >

                >

                > >

                >

                > > On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:

                >

                > >

                >

                > > > Hi All,

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > I have a subroutine to create a daemon, subroutine is pasted below.

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > ub Daemonize() {

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > my $pid;

                >

                > >

                >

                > > > $pid=fork();

                >

                > >

                >

                > > > if(! defined($pid) ){

                >

                > >

                >

                > > > #Forking Failed, we exit at this point

                >

                > >

                >

                > > > die("forking failed\n");

                >

                > >

                >

                > > > exit(1);

                >

                > >

                >

                > > > }

                >

                > >

                >

                > > > if ($pid>0) {

                >

                > >

                >

                > > > print LOG "Forking Success. Child PID: $pid \n";

                >

                > >

                >

                > > > exit();

                >

                > >

                >

                > > > }

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > $|=1;

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > print LOG "Child Process Executing... \n";

                >

                > >

                >

                > > > setsid();

                >

                > >

                >

                > > > chdir('/');

                >

                > >

                >

                > > > umask(0);

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > close(STDIN) ;

                >

                > >

                >

                > > > close(STDOUT) ;

                >

                > >

                >

                > > > close(STDERR) ;

                >

                > >

                >

                > > > }

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > Can anyone please help me ?.

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > Shammi

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > ------------ --------- --------- ------

                >

                > >

                >

                > > >

                >

                > >

                >

                > > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > >

                >

                > > [Non-text portions of this message have been removed]

                >

                > >

                >

                > >

                >

                > >

                >

                > > ------------ --------- --------- ------

                >

                > >

                >

                > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links

                >

                > >

                >

                > >

                >

                > >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                >

                > [Non-text portions of this message have been removed]

                >

                >

                >

                > ------------ --------- --------- ------

                >

                > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links

                >

                >

                >

























                [Non-text portions of this message have been removed]
              • James Washer
                Perhaps it s time to use the perl debugger
                Message 7 of 8 , Jan 27, 2010
                • 0 Attachment
                  Perhaps it's time to use the perl debugger

                  On Wed, 2010-01-27 at 19:21 +0530, Shameem Ahamed wrote:
                  > Hello James.
                  >
                  > How i know ?. Because in the Slow query kill function, i am killing all the slow queries. and it is not happening. I can see the child process running , when i try ps.
                  >
                  > But it is not doing the tasks. I am really confused.
                  >
                  >
                  > Shammi
                  >
                  >
                  >
                  > --- On Wed, 1/27/10, James Washer <washergrp@...> wrote:
                  >
                  > From: James Washer <washergrp@...>
                  > Subject: Re: [PBML] Perl forking acting wierd
                  > To: perl-beginner@yahoogroups.com
                  > Date: Wednesday, January 27, 2010, 1:43 PM
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  > Once again.. HOW DO YOU KNOW IT IS NOT GETTING EXECUTED?
                  >
                  > Sorry for the caps, but it's been a trial getting information from you.
                  >
                  > I still don't know how you know it's not getting executed.. but, just
                  >
                  > for kicks.. put a die in your sub and see if it dies.
                  >
                  >
                  >
                  > - jim
                  >
                  >
                  >
                  > On Wed, 2010-01-27 at 13:19 +0530, Shameem Ahamed wrote:
                  >
                  > > As you can see in the code, i am calling the function Slow_Query_Kill in the child process.
                  >
                  > >
                  >
                  > > This function is not getting executed.
                  >
                  > >
                  >
                  > > My logic is, create a child process, exit the parent, make child the session leader and run the function Sleep_Query_ Kill in the child indefinitely.
                  >
                  > >
                  >
                  > >
                  >
                  > > Regards,
                  >
                  > > Shameem
                  >
                  > >
                  >
                  > > --- On Wed, 1/27/10, James Washer <washergrp@trlp. com> wrote:
                  >
                  > >
                  >
                  > > From: James Washer <washergrp@trlp. com>
                  >
                  > > Subject: Re: [PBML] Perl forking acting wierd
                  >
                  > > To: perl-beginner@ yahoogroups. com
                  >
                  > > Date: Wednesday, January 27, 2010, 2:19 AM
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > > And what did the problem do to lead you to think that it couldn't call
                  >
                  > >
                  >
                  > > functions.
                  >
                  > >
                  >
                  > > On Wed, 2010-01-27 at 00:17 +0530, Shameem Ahamed wrote:
                  >
                  > >
                  >
                  > > > LOG was opened before calling the daemon function in the global scope.
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > This is the entire program.
                  >
                  > >
                  >
                  > > > I am calling other function after calling daemon , which should be running in child process.
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > open(LOG,">> $LOGFILE") || die("Unable to create Log file $LOGFILE : $! \n Please run as SUPER user");
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > &readConfigXML( $config_file) ;
                  >
                  > >
                  >
                  > > > &Daemonize() ;
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > while(1)
                  >
                  > >
                  >
                  > > > {
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > &Slow_Query_ Kill();
                  >
                  > >
                  >
                  > > > sleep($slowtime)
                  >
                  > >
                  >
                  > > > }
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > close(LOG);
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > --- On Wed, 1/27/10, James Washer <washergrp@trlp. com> wrote:
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > From: James Washer <washergrp@trlp. com>
                  >
                  > >
                  >
                  > > > Subject: Re: [PBML] Perl forking acting wierd
                  >
                  > >
                  >
                  > > > To: perl-beginner@ yahoogroups. com
                  >
                  > >
                  >
                  > > > Date: Wednesday, January 27, 2010, 12:02 AM
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > Was LOG open?
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > What do you mean it is unable to call other functions?
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > - jim
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > On Tue, 2010-01-26 at 23:49 +0530, Shameem Ahamed wrote:
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > Hi All,
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > I have a subroutine to create a daemon, subroutine is pasted below.
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > ub Daemonize() {
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > my $pid;
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > $pid=fork();
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > if(! defined($pid) ){
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > #Forking Failed, we exit at this point
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > die("forking failed\n");
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > exit(1);
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > }
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > if ($pid>0) {
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > print LOG "Forking Success. Child PID: $pid \n";
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > exit();
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > }
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > $|=1;
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > print LOG "Child Process Executing... \n";
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > setsid();
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > chdir('/');
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > umask(0);
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > close(STDIN) ;
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > close(STDOUT) ;
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > close(STDERR) ;
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > }
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > I ran in to an issue in this code. In the child process (which becomes the session leader), I am not getting any data logged or the child process is not able to call even the other functions.
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > Can anyone please help me ?.
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > Shammi
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > ------------ --------- --------- ------
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > [Non-text portions of this message have been removed]
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > ------------ --------- --------- ------
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > > [Non-text portions of this message have been removed]
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  > > ------------ --------- --------- ------
                  >
                  > >
                  >
                  > > Unsubscribing info is here: http://help. yahoo.com/ help/us/groups/ groups-32. htmlYahoo! Groups Links
                  >
                  > >
                  >
                  > >
                  >
                  > >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  > [Non-text portions of this message have been removed]
                  >
                  >
                  >
                  > ------------------------------------
                  >
                  > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
                  >
                  >
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.