Jump to content

Search the Community

Showing results for tags 'php linux unix'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I am executing two child process using proc open in PHP. After both the process are created I access the stdout of first process but it gives error that the descriptor is not valid, where as the output of second process is displayed. It seems that the pipes that were attached with stdout of first process are no more connected with it and instead they are pointing to second process. How can I have correct display of both the processes? PHP Code <?php echo "Executing a process\n"; $cwd = '/var/www/html/test-9-5-14'; $exe_command = ('/var/www/html/test-9-5-14/./hello'); $descriptorspec = array( 0 => array("pipe", "r"), // stdin -> for execution 1 => array("pipe", "w"), // stdout -> for execution 2 => array("pipe", "w") // stderr ); $process = proc_open($exe_command, $descriptorspec, $pipes, $cwd);//creating child process stream_set_blocking($pipes[1], 0); stream_set_blocking($pipes[0], 0); stream_set_blocking($pipes[2], 0); sleep(1); if (is_resource($process)) { echo "Process Created"; $stdout1 = array($pipes[1]);//save stdout in a variable defined above print_r ($stdout1); } $exe_command = ('/var/www/html/test-9-5-14/./add'); $descriptorspec = array( 0 => array("pipe", "r"), // stdin -> for execution 1 => array("pipe", "w"), // stdout -> for execution 2 => array("pipe", "w") // stderr ); $process = proc_open($exe_command, $descriptorspec, $pipes1, $cwd);//creating child process stream_set_blocking($pipes1[1], 0); stream_set_blocking($pipes1[0], 0); stream_set_blocking($pipes1[2], 0); sleep(1); if (is_resource($process)) { echo "Process 2 Created"; $stdout2 = array($pipes1[1]);//save stdout in a variable defined above print_r ($stdout2); } $s = fgets($stdout1[0]); echo $s; $s = fgets($stdout2[0]); echo $s; ?> Output Executing a process Process CreatedArray ( [0] => Resource id #5 ) Process 2 CreatedArray ( [0] => Resource id #9 ) PHP Warning: fgets(): 5 is not a valid stream resource in /var/www/html/test-9-5-14/test.php on line 70 --Enter two integers > --Enter two integers > is the output of my second process whereas the first process stdout descriptor 5 is invalid. Any ideas please. Thank you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.