diff --git a/runtime/v2/binary.go b/runtime/v2/binary.go index 51845bfee..5a62a86b6 100644 --- a/runtime/v2/binary.go +++ b/runtime/v2/binary.go @@ -133,11 +133,13 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_ func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) { log.G(ctx).Info("cleaning up dead shim") - // Windows cannot delete the current working directory while an - // executable is in use with it. For the cleanup case we invoke with the - // default work dir and forward the bundle path on the cmdline. + // On Windows and FreeBSD, the current working directory of the shim should + // not be the bundle path during the delete operation. Instead, we invoke + // with the default work dir and forward the bundle path on the cmdline. + // Windows cannot delete the current working directory while an executable + // is in use with it. On FreeBSD, fork/exec can fail. var bundlePath string - if gruntime.GOOS != "windows" { + if gruntime.GOOS != "windows" && gruntime.GOOS != "freebsd" { bundlePath = b.bundle.Path } @@ -160,6 +162,7 @@ func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) { cmd.Stdout = out cmd.Stderr = errb if err := cmd.Run(); err != nil { + log.G(ctx).WithField("cmd", cmd).WithError(err).Error("failed to delete") return nil, errors.Wrapf(err, "%s", errb.String()) } s := errb.String()