Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7882719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:21:04+00:00 2026-06-03T04:21:04+00:00

I am trying to run processes using proc_open() function. As specified on the page

  • 0

I am trying to run processes using proc_open() function. As specified on the page – I supplied the custom environment variables and tried to print out. It shows all of my supplied variables + always 3 variables : ‘SHLVL’, ‘PWD’, ‘_=’. I would like to print/use only my supplied environment variables. Are these 3 always present with this function? Is there any way to have only provided variables? This is all under Linux and PHP5.

//Here is the code to clarify : 
$descriptorspec = array(
0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);

$env = array('MY_VAR' => 'FOO');

$process = proc_open('./run.php', $descriptorspec, $pipes, $cwd, $env);

if (is_resource($process)) {

fwrite($pipes[0], escapeshellcmd($args));
fclose($pipes[0]);

$output = "";
while (!feof($pipes[1])) {
    $output .= fgets($pipes[1]);
}

print "Output is $output \n";
    fclose($pipes[1]);
    $return_value = proc_close($process);

}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:21:05+00:00Added an answer on June 3, 2026 at 4:21 am

    You could namespace your environment variables, e.g. PHP_MYVAR instead of MYVAR. This way you can filter based on the common prefix PHP_.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run a simple multiple processes application in Python. The main
I'm trying to work out how to run a process in a background thread
I'm trying out the Runtime.exec() method to run a command line process. I wrote
I'm using python 2.7, and trying to run some CPU heavy tasks in their
I am trying to write a class that will calculate checksums using multiple processes,
I'm trying to run an external problem from C# by using Process.Start, but am
I am trying to create multiple processes using fork() and execvp() calls, but so
Am trying to run a selenium suite using this code which runs perfectly on
I am trying to run 2 activities on 2 different processes. The purpose of
I am trying to implement a thread pool that processes a task queue using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.