Welcome Guest, Not a member yet? Register   Sign In
i have this error Fatal error: Call to undefined function pcntl_fork() in /var/www/onplans/application/models/api_repor
#1

[eluser]dinisptc[/eluser]
i have this error Fatal error: Call to undefined function pcntl_fork() in /var/www/onplans/application/models/api_report_model.php on line 94

i went to php.ini disable functions

; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
;disable_functions pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,


i think pcntl its installed

$ php -m | grep pcntl
pcntl

and its installed

i am missing something here ?

i am going to show function where iam using fork

Code:
if ($pid = pcntl_fork())
            return;     // Parent
             ob_end_clean(); // Discard the output buffer and close

        fclose(STDIN);  // Close all of the standard
        fclose(STDOUT); // file descriptors as we
        fclose(STDERR); // are running as a daemon.

        register_shutdown_function('shutdown');

        if (posix_setsid() < 0)
            return;

        if ($pid = pcntl_fork())
            return;     // Parent

        // Now running as a daemon. This process will even survive
        // an apachectl stop.

        sleep(10);

          
           //gerar o report
           /* initial data */
           $Ddata['page_details'] = array('page_title' => 'Listar Artigos');
           $Dheader = array();
           $Dmeta = array('meta_title'=>'Bemvindo a dinispt','meta_descricao'=>'List my meetings');
           $DContent['page_details'] = array('page_title' => 'Index of onplans');
           $Dsidebar = array();
        $Dfooter = array();  
        
        //get projectid
        $projectID=$this->get_project_ID($j->projectUID);          
        $meetingID=$this->get_meeting($j->meetingUID);
        
        $projectUID=$projectID['id'];
        $meetingUID=$meetingID['idm'];

        //$Ddata['timeline']=$this->timeline_model->listar_timeline_onlyreports(0,0,$projectuid);

        $Ddata['meetproj']=$this->timeline_model->listar_project_meeting($projectUID,$meetingUID);
        $Ddata['meetpresences']=$this->timeline_model->listar_presences_contractors($meetingUID);
        //demands
        $Ddata['demands']=$this->timeline_model->listar_timeline_demands($projectUID);
          
        $this->load->library('pdf');
        $this->pdf->load_view('onplans/list_my_project_meeting',$Ddata);
        $this->pdf->render();
        // $this->pdf->stream("BEMVINDO.pdf",array("compress" => true));
        date_default_timezone_set("UTC");
        $file_name="report_".date("Y-m-d-H:i:s", time());
        $report_config = $this->config->item('report');
      
        
        $report_dir=$report_config['upload_path'].$this->projects_model->check_user_id().'/'.$projectUID.'/report/';
        
        
       // print_r($report_dir);
        if (!is_dir($report_dir))
        {
      mkdir($report_dir,0777,true);
        }
                        
        $pdfoutput = $this->pdf->output();

        $filename ="$report_dir/$file_name.pdf";
        $file_name="$file_name.pdf";
        
        
        $fp = fopen($filename, "a");
        fwrite($fp, $pdfoutput);
        fclose($fp);
    
        //gravar o filename na base de dados
        $this->report_model->add("report_".date("Y-m-d-H:i:s", time()),0,' ',$meetingUID,$file_name);

          
                    
     // $report=$this->report_model->get_by_meetingUUID($j->meetingUID);
           file_put_contents(APPPATH.'logs/HEEEEAAAAAAAAADDDDDDER_TEXT_SPECIALCHARS'.EXT, date('Y-m-d H:i:s').' -> '.print_r($j->header_text, true));
           return true;
    // $report;
        }
        else
        {
           return false;
        }


          
     }else
     {
         return false;
     }



}

#2

[eluser]dinisptc[/eluser]
Code:
instalation of
pcntl
$ mkdir /tmp/phpsource
$ cd /tmp/phpsource
$ apt-get source php5
$ cd /tmp/phpsource/php5-*/ext/pcntl
$ phpize
$ ./configure
$ make
# then copy your module to php5 module-lib path (in my case:)
# and create an .ini-file to enable the module for sapi after graceful restart.

$ cp /tmp/phpsource/php5-*/modules/pcntl.so /usr/lib/php5/20090626/
$ echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini

on php.ini you need to
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
;disable_functions pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
#3

[eluser]dinisptc[/eluser]
now on my localhost its working well

but on the server i am getting this errors :


A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant STDIN - assumed 'STDIN'

Filename: models/api_report_model.php

Line Number: 140
A PHP Error was encountered

Severity: Warning

Message: fclose() expects parameter 1 to be resource, string given

Filename: models/api_report_model.php

Line Number: 140
A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant STDOUT - assumed 'STDOUT'

Filename: models/api_report_model.php

Line Number: 141
A PHP Error was encountered

Severity: Warning

Message: fclose() expects parameter 1 to be resource, string given

Filename: models/api_report_model.php

Line Number: 141
A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant STDERR - assumed 'STDERR'

Filename: models/api_report_model.php

Line Number: 142
A PHP Error was encountered

Severity: Warning

Message: fclose() expects parameter 1 to be resource, string given

Filename: models/api_report_model.php

Line Number: 142


Code:
if( is_callable('pcntl_fork') ) // NOTE: not enabled in php5-fpm (via dotdeb)
{
     if( $pid = pcntl_fork() )
         return true; // Parent
  
     function shutdown_kill()
     {
         posix_kill(posix_getpid(), SIGHUP);
     }
  
     ob_end_clean(); // Discard the output buffer and close

//the errors are here
[b]     fclose(STDIN);  // Close all of the standard
     fclose(STDOUT); // file descriptors as we
     fclose(STDERR); // are running as a daemon.[/b]
  
     register_shutdown_function('shutdown_kill');
  
            file_put_contents(APPPATH.'logs/posix_setsid'.EXT, date('Y-m-d H:i:s').' -> '.print_r(posix_setsid(), true));
     if( posix_setsid() < 0 )
         return true;
  
     if( $pid = pcntl_fork() )
         return true;     // Parent
            file_put_contents(APPPATH.'logs/PIDDD11111111111'.EXT, date('Y-m-d H:i:s').' -> '.print_r($pid, true));
  
     // Now running as a daemon. This process will even survive
     // an apachectl stop.
}







Theme © iAndrew 2016 - Forum software by © MyBB