Skip to content
Merged
Changes from all 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
7 changes: 5 additions & 2 deletions pkg/networks/usernet/recoincile.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func Stop(ctx context.Context, name string) error {
return err
}

if err := osutil.SysKill(pid, osutil.SigKill); err != nil {
if err := osutil.SysKill(pid, osutil.SigInt); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fallback to SIGKILL on an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error there should only occur when the signal cannot be sent.
Process monitoring is required to fall back to SIGKILL.
Should process monitoring be included?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go func(){ Sleep(3 * second); SysKill(pid, SigKill) }() may suffice, unless the PID is reused for another process within the 3 seconds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me postpone this PR to v2.0.1 (or later)

logrus.Error(err)
return fmt.Errorf("failed to kill process with pid %d: %w", pid, err)
}
Expand All @@ -157,7 +157,10 @@ func Stop(ctx context.Context, name string) error {
break
}
if time.Since(startWaiting) > 5*time.Second {
logrus.Infof("usernet network still running after 5 seconds")
logrus.Infof("usernet network still running after 5 seconds. Attempting to forcibly kill")
if err := osutil.SysKill(pid, osutil.SigKill); err != nil {
logrus.Error(err)
}
break
}
time.Sleep(500 * time.Millisecond)
Expand Down
Loading