Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite8e16c9

Browse files
chore(agent/agentscripts): log command cancellation (#16324)
Relates tocoder/internal#329It's currently unclear where the SIGHUP came from; adding some loggingto make it more clear if it happens again in future.---------Co-authored-by: Danny Kopping <danny@coder.com>
1 parentd389744 commite8e16c9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

‎agent/agentscripts/agentscripts.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript,
290290
cmd=cmdPty.AsExec()
291291
cmd.SysProcAttr=cmdSysProcAttr()
292292
cmd.WaitDelay=10*time.Second
293-
cmd.Cancel=cmdCancel(cmd)
293+
cmd.Cancel=cmdCancel(ctx,logger,cmd)
294294

295295
// Expose env vars that can be used in the script for storing data
296296
// and binaries. In the future, we may want to expose more env vars

‎agent/agentscripts/agentscripts_other.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
package agentscripts
44

55
import (
6+
"context"
67
"os/exec"
78
"syscall"
9+
10+
"cdr.dev/slog"
811
)
912

1013
funccmdSysProcAttr()*syscall.SysProcAttr {
@@ -13,8 +16,9 @@ func cmdSysProcAttr() *syscall.SysProcAttr {
1316
}
1417
}
1518

16-
funccmdCancel(cmd*exec.Cmd)func()error {
19+
funccmdCancel(ctx context.Context,logger slog.Logger,cmd*exec.Cmd)func()error {
1720
returnfunc()error {
21+
logger.Debug(ctx,"cmdCancel: sending SIGHUP to process and children",slog.F("pid",cmd.Process.Pid))
1822
returnsyscall.Kill(-cmd.Process.Pid,syscall.SIGHUP)
1923
}
2024
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package agentscripts
22

33
import (
4+
"context"
45
"os"
56
"os/exec"
67
"syscall"
8+
9+
"cdr.dev/slog"
710
)
811

912
funccmdSysProcAttr()*syscall.SysProcAttr {
1013
return&syscall.SysProcAttr{}
1114
}
1215

13-
funccmdCancel(cmd*exec.Cmd)func()error {
16+
funccmdCancel(ctx context.Context,logger slog.Logger,cmd*exec.Cmd)func()error {
1417
returnfunc()error {
18+
logger.Debug(ctx,"cmdCancel: sending interrupt to process",slog.F("pid",cmd.Process.Pid))
1519
returncmd.Process.Signal(os.Interrupt)
1620
}
1721
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp