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

  • Home
  • SEARCH
  • 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 8089343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:21:58+00:00 2026-06-05T19:21:58+00:00

Say I have a PHP script, //main.php -> PID = 1002 <?php exec(‘ProcessOne’); exec(‘ProcessTwo’);

  • 0

Say I have a PHP script,

//main.php -> PID = 1002
<?php 
exec('ProcessOne');
exec('ProcessTwo');
//... many other exec calls
?>

The main.php creates many other processes with their own pids which may not be recorded/tracked by the script, but the pid of main.php is known.

My question is: how do I kill all those processes created by main.php(including main.php) by only knowing the pid of main.php which is 1002 in my example?

The script should run in Linux.

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-05T19:21:59+00:00Added an answer on June 5, 2026 at 7:21 pm
    pkill -TERM -P 1002
    

    pkill -P PID gives you all child-proccess, -TERM sends the TERM Signal to all children.

    To kill the children of the children:

    kill `pstree -p 1002 | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " "`
    

    Modified version from Walking a process tree.

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

Sidebar

Related Questions

I have a php script written which calls an external command using exec which
Say I have a PHP script that creates a cookie that expires 10 days
I have a PHP script on a domain (say example.com) and this domain has
I have a PHP script where I have an array of integers, let's say
Just say I have a file configuration.xml that a php script needs to parse
Let's say I have to following php script: $str = be43f751d380a70d13287006a5f7795a; $arr = str_split($str,
I have a PHP script, say a.php , which is called from JS using
So, say you have a php post script that appends whatever you pass to
Let's say I have a PHP class called Color , it's constructor accepts various
I have a problem with my path. Say I have a PHP file in

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.