How it works...

The sample code consists of a target function, foo(), whose task is to print out the first 10 integer numbers on the screen. In the main program, the process is executed and then killed by the terminate instruction. The process is then joined and ExitCode is determined.

To run the code, type the following command:

> python killing_processes.py

Then, we get the following output:

Process before execution: <Process(Process-1, initial)> False
Process running: <Process(Process-1, started)> True
Process terminated: <Process(Process-1, started)> True
Process joined: <Process(Process-1, stopped[SIGTERM])> False
Process exit code: -15

Notice that the output value of the ExitCode code is equal to -15. The negative value of -15 indicates that the child was terminated by an interrupt signal, which is identified by the number 15.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.157.186