Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
b62f86cd
Commit
b62f86cd
authored
Jul 30, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add brute force process group clean-up
parent
8b14e2e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
main.go
main.go
+18
-0
No files found.
main.go
View file @
b62f86cd
...
...
@@ -189,6 +189,7 @@ func handleGetInfoRefs(env gitEnv, _ string, path string, w http.ResponseWriter,
return
}
defer
cmd
.
Wait
()
defer
sigKillProcessGroup
(
cmd
)
// Ensure brute force subprocess clean-up
// Start writing the response
w
.
Header
()
.
Add
(
"Content-Type"
,
fmt
.
Sprintf
(
"application/x-%s-advertisement"
,
rpc
))
...
...
@@ -258,6 +259,7 @@ func handlePostRPC(env gitEnv, rpc string, path string, w http.ResponseWriter, r
return
}
defer
cmd
.
Wait
()
defer
sigKillProcessGroup
(
cmd
)
// Ensure brute force subprocess clean-up
// Write the client request body to Git's standard input
if
_
,
err
:=
io
.
Copy
(
stdin
,
body
);
err
!=
nil
{
...
...
@@ -296,3 +298,19 @@ func fail500(w http.ResponseWriter, err error) {
func
setHeaderNoCache
(
w
http
.
ResponseWriter
)
{
w
.
Header
()
.
Add
(
"Cache-Control"
,
"no-cache"
)
}
func
sigKillProcessGroup
(
cmd
*
exec
.
Cmd
)
{
if
cmd
==
nil
{
return
}
process
:=
cmd
.
Process
if
process
==
nil
{
return
}
if
process
.
Pid
>
0
{
// Send SIGKILL (kill -9) to the process group of cmd
syscall
.
Kill
(
-
process
.
Pid
,
syscall
.
SIGKILL
)
}
}
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