Python | os.WIFSTOPPED() method

OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.

os.WIFSTOPPED() method in Python is used to check whether a process has been stopped. This method takes process status code as returned by os.wait(), os.system() or os.waitpid() method as a parameter and returns True if the process has been stopped, otherwise returns False.

Syntax: os.WIFSTOPPED(status)

status: This parameter takes process status code (an integer value) as returned by os.system(), os.wait() or os.waitpid() method.

Return type: This method returns a boolean value of class ‘bool’. This method returns True if the process has been stopped, otherwise returns False.

Code: Use of os.WIFSTOPPED() method





# Python program to explain os.WIFSTOPPED() method 
# importing os and signal module  
import os, signal
# Create a child process
# using os.fork() method 
pid = os.fork()
# pid greater than 0
# indicates the parent process 
if pid :
    # Send signal 'SIGSTOP'
    # to child process
    # using os.kill() method
    # signal will cause the child
    # process to stop
    os.kill(pid, signal.SIGSTOP)
    # Get the child's pid and 
    # status code using
    # os.waitpid() method
    info = os.waitpid(pid, os.WSTOPPED)
    # info is a tuple
    # info[0] represents child's pid
    # info[1] represents exit status code
    print("\nIn parent process")
    # Check whether the child process
    # has been stopped or not    
    # using os.WIFSTOPPED() method
    isStopped = os.WIFSTOPPED(info[1]) 
    print("Has child process been stopped?")
else :
    print("In Child process")
    print("Process ID:", os.getpid())
    print("Hello ! Geeks")



In Child process
Process ID: 10224
Hello! Geeks

In parent process
Has child process been stopped?


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

self motivated and passionate programmer

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.