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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-workhorse
Commits
e34d9bc4
Commit
e34d9bc4
authored
Jul 30, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait() after killing processes
parent
b62f86cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
main.go
main.go
+7
-10
No files found.
main.go
View file @
e34d9bc4
...
...
@@ -188,8 +188,7 @@ func handleGetInfoRefs(env gitEnv, _ string, path string, w http.ResponseWriter,
fail500
(
w
,
err
)
return
}
defer
cmd
.
Wait
()
defer
sigKillProcessGroup
(
cmd
)
// Ensure brute force subprocess clean-up
defer
cleanUpProcessGroup
(
cmd
)
// Ensure brute force subprocess clean-up
// Start writing the response
w
.
Header
()
.
Add
(
"Content-Type"
,
fmt
.
Sprintf
(
"application/x-%s-advertisement"
,
rpc
))
...
...
@@ -258,8 +257,7 @@ func handlePostRPC(env gitEnv, rpc string, path string, w http.ResponseWriter, r
fail500
(
w
,
err
)
return
}
defer
cmd
.
Wait
()
defer
sigKillProcessGroup
(
cmd
)
// Ensure brute force subprocess clean-up
defer
cleanUpProcessGroup
(
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
{
...
...
@@ -299,18 +297,17 @@ func setHeaderNoCache(w http.ResponseWriter) {
w
.
Header
()
.
Add
(
"Cache-Control"
,
"no-cache"
)
}
func
sigKill
ProcessGroup
(
cmd
*
exec
.
Cmd
)
{
func
cleanUp
ProcessGroup
(
cmd
*
exec
.
Cmd
)
{
if
cmd
==
nil
{
return
}
process
:=
cmd
.
Process
if
process
==
nil
{
return
}
if
process
.
Pid
>
0
{
if
process
!=
nil
&&
process
.
Pid
>
0
{
// Send SIGKILL (kill -9) to the process group of cmd
syscall
.
Kill
(
-
process
.
Pid
,
syscall
.
SIGKILL
)
}
// reap our child process
cmd
.
Wait
()
}
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