RosettaCodeData/Task/Determine-if-only-one-instance-is-running/Python/determine-if-only-one-instance-is-running.py
2023-07-01 13:44:08 -04:00

8 lines
339 B
Python

import __main__, os
def isOnlyInstance():
# Determine if there are more than the current instance of the application
# running at the current time.
return os.system("(( $(ps -ef | grep python | grep '[" +
__main__.__file__[0] + "]" + __main__.__file__[1:] +
"' | wc -l) > 1 ))") != 0