Results 1 to 4 of 4

Thread: Capture a PID as a Variable

  1. #1
    Join Date
    Mar 2008
    Beans
    358
    Distro
    Ubuntu

    Question Capture a PID as a Variable

    I'm writing a small program which involves a background process. I'm using the "&" attribute with UNIX and it prints the PID, but not in the script. I know it's been stored somewhere, but I want to capture the PID, so when the user want to close the script, the background process is killed by that stored PID!

  2. #2
    Join Date
    Sep 2009
    Location
    Freiburg/Germany
    Beans
    1,112
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Capture a PID as a Variable

    Code:
    background_process &
    PID="$!"
    ClassicMenu Indicator - classic GNOME menu for Unity
    Unsettings - configuration program for the Unity
    Privacy Indicator - easily switch privacy settings in Unity
    Arronax - create and modify app starters

  3. #3
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

  4. #4
    Join Date
    Mar 2008
    Beans
    358
    Distro
    Ubuntu

    Re: Capture a PID as a Variable

    Awesome, I'll give those a try!!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •