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

chore(agent/agentscripts): log command cancellation#16324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 2 commits intomainfromcj/agentscripts/log-cmd-cancel
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionagent/agentscripts/agentscripts.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -290,7 +290,7 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript,
cmd = cmdPty.AsExec()
cmd.SysProcAttr = cmdSysProcAttr()
cmd.WaitDelay = 10 * time.Second
cmd.Cancel = cmdCancel(cmd)
cmd.Cancel = cmdCancel(ctx, logger,cmd)

// Expose env vars that can be used in the script for storing data
// and binaries. In the future, we may want to expose more env vars
Expand Down
6 changes: 5 additions & 1 deletionagent/agentscripts/agentscripts_other.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,11 @@
package agentscripts

import (
"context"
"os/exec"
"syscall"

"cdr.dev/slog"
)

func cmdSysProcAttr() *syscall.SysProcAttr {
Expand All@@ -13,8 +16,9 @@ func cmdSysProcAttr() *syscall.SysProcAttr {
}
}

func cmdCancel(cmd *exec.Cmd) func() error {
func cmdCancel(ctx context.Context, logger slog.Logger,cmd *exec.Cmd) func() error {
return func() error {
logger.Debug(ctx, "cmdCancel: sending SIGHUP to process and children", slog.F("pid", cmd.Process.Pid))
return syscall.Kill(-cmd.Process.Pid, syscall.SIGHUP)
}
}
6 changes: 5 additions & 1 deletionagent/agentscripts/agentscripts_windows.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
package agentscripts

import (
"context"
"os"
"os/exec"
"syscall"

"cdr.dev/slog"
)

func cmdSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{}
}

func cmdCancel(cmd *exec.Cmd) func() error {
func cmdCancel(ctx context.Context, logger slog.Logger,cmd *exec.Cmd) func() error {
return func() error {
logger.Debug(ctx, "cmdCancel: sending interrupt to process", slog.F("pid", cmd.Process.Pid))
return cmd.Process.Signal(os.Interrupt)
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp