You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: exec.go
    path of file: ./repos/podman/vendor/github.com/containers/common/pkg/hooks/exec
    
    the code of the file until where you have to start completion: // Package exec provides utilities for executing Open Container Initiative runtime hooks.
package exec

import (
	"bytes"
	"context"
	"fmt"
	"io"
	osexec "os/exec"
	"time"

	rspec "github.com/opencontainers/runtime-spec/specs-go"
	"github.com/sirupsen/l
    
func RunWithOptions(ctx context.Context, options RunOptions) (hookErr, err error) {
	hook := options.Hook
	cmd := osexec.Cmd{
		Path:   hook.Path,
		Args:   hook.Args,
		Env:    hook.Env,
		Dir:    options.Dir,
		Stdin:  bytes.NewReader(options.State),
		Stdout: options.Stdout,
		Stderr: options.Stderr,
	}
	if cmd.Env == nil {
		cmd.Env = []string{}
	}

	if hook.Timeout != nil {
		var cancel context.CancelFunc
		ctx, cancel = context.WithTimeout(ctx, time.Duration(*hook.Timeout)*time.Second)
		defer cancel()
	}

	err = cmd.Start()
	if err != nil {
		return err, err
	}
	exit := make(chan error, 1)
	go func() {
		err := cmd.Wait()
		if err != nil {
			err = fmt.Errorf("executing %v: %w", cmd.Args, err)
		}
		exit <- err
	}()

	select {
	case err = <-exit:
		return err, err
	case <-ctx.Done():
		if err := cmd.Process.Kill(); err != nil {
			logrus.Errorf("Failed to kill pid %v", cmd.Process)
		}
		timer := time.NewTimer(options.PostKillTimeout)
		defer timer.Stop()
		select {
		case <-timer.C:
			err = fmt.Errorf("failed to reap process within %s of the kill signal", options.PostKillTimeout)
		case err = <-exit:
		}
		return err, ctx.Err()
	}
}