Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
SHMCamStudio
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
SHMCamStudio
Commits
bde2b83d
Commit
bde2b83d
authored
Nov 09, 2024
by
robocoders.ai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated create_daemon() function for cross-platform compatibility
parent
f4bddbcc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
8 deletions
+54
-8
shmcamstudio
shmcamstudio
+54
-8
No files found.
shmcamstudio
View file @
bde2b83d
...
...
@@ -92,7 +92,7 @@ def stream():
return
render_template
(
'stream.html'
,
stream_url
=
stream_url
)
def
create_daemon
():
"""Create a Unix-style daemon process"""
if
os
.
name
==
'posix'
:
# Unix-like systems
try
:
# First fork
pid
=
os
.
fork
()
...
...
@@ -108,6 +108,52 @@ def create_daemon():
os
.
setsid
()
os
.
umask
(
0
)
# Second fork
try
:
pid
=
os
.
fork
()
if
pid
>
0
:
# Exit from second parent
sys
.
exit
(
0
)
except
OSError
as
err
:
sys
.
stderr
.
write
(
f
'Fork #2 failed: {err}
\n
'
)
sys
.
exit
(
1
)
# Redirect standard file descriptors
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
si
=
open
(
os
.
devnull
,
'r'
)
so
=
open
(
os
.
devnull
,
'a+'
)
se
=
open
(
os
.
devnull
,
'a+'
)
os
.
dup2
(
si
.
fileno
(),
sys
.
stdin
.
fileno
())
os
.
dup2
(
so
.
fileno
(),
sys
.
stdout
.
fileno
())
os
.
dup2
(
se
.
fileno
(),
sys
.
stderr
.
fileno
())
elif
os
.
name
==
'nt'
:
# Windows
try
:
# Hide the console window
si
=
subprocess
.
STARTUPINFO
()
si
.
dwFlags
|=
subprocess
.
STARTF_USESHOWWINDOW
# Start the script as a new process
subprocess
.
Popen
([
sys
.
executable
,
__file__
],
startupinfo
=
si
,
creationflags
=
subprocess
.
CREATE_NEW_PROCESS_GROUP
)
# Exit the current process
sys
.
exit
(
0
)
except
Exception
as
err
:
sys
.
stderr
.
write
(
f
'Failed to create background process: {err}
\n
'
)
sys
.
exit
(
1
)
else
:
sys
.
stderr
.
write
(
f
'Unsupported operating system: {os.name}
\n
'
)
sys
.
exit
(
1
)
# Decouple from parent environment
os
.
chdir
(
'/'
)
os
.
setsid
()
os
.
umask
(
0
)
# Second fork
try
:
pid
=
os
.
fork
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment