-
Notifications
You must be signed in to change notification settings - Fork 3
/
virus.py
49 lines (42 loc) · 971 Bytes
/
virus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python2
import os, sys
def forkSuccessful():
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError:
return 0
os.setsid()
os.umask(0)
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError:
return 0
return 1
def iseSURJTiXTid(duLZajeLU):
try:
os.kill(duLZajeLU, 0)
except OSError:
return
else:
return duLZajeLU
def writePID(pidFilePath):
if os.path.exists(pidFilePath):
try:
if iseSURJTiXTid(int(open(pidFilePath).read())):
os.kill(os.getpid(),9)
else:
os.remove(pidFilePath)
except:
try:
os.remove(pidFilePath)
except:
pass
open(pidFilePath, 'w').write(str(os.getpid()))
return pidFilePath
if forkSuccessful():
writePID(".pidw")
print("Hello from FORK!")