1

This simple Python program :

import threading
import time
import os

def run_test():

    print("run_test pid : " + str(os.getpid()))

    while True:
        time.sleep(100)

print("main pid : " + str(os.getpid()))
thread1 = threading.Thread(target=run_test)
thread1.start()

Starts multiple processes according to htop:

enter image description here

With PIDs 12004 and 12040.

However, there doesn't appear to be any point in the program where the second process is created.

Where does the second process come from ?

8
  • Which version of Python are you running? The code only shows one process when I run it on 2.7.10
    – l'L'l
    Jul 23, 2016 at 17:11
  • I'm running Python3.5
    – Kalessar
    Jul 23, 2016 at 17:13
  • This process runs forever... sure you don't have an old one running along with the new one?
    – tdelaney
    Jul 23, 2016 at 17:13
  • If you haven't tried already, i would kill all of the processes in question and test it again...
    – l'L'l
    Jul 23, 2016 at 17:15
  • 1
    Apparently it is due to the fact that vanilla htop doesn't distinguish between process identifiers and thread identifiers without activating options ( source : my roommate )
    – Kalessar
    Jul 23, 2016 at 17:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.