func RunHooks(ctx context.Context, state *specs.State, hooks []specs.Hook, continueOnError bool) error {
	if len(hooks) == 0 {
		return nil
	}
	stateJSON, err := json.Marshal(state)
	if err != nil {
		return fmt.Errorf("failed to serialize spec state: %w", err)
	}
	for i, h := range hooks {
		fmt.Printf("running hook[%d] path:%s\n", i, h.Path)
		err := RunHook(ctx, stateJSON, h)
		if err != nil {
			fmt.Printf("hook[%d] failed: %s\n", i, err)
			if !continueOnError {
				return err
			}
		}
	}
	return nil
}
RunHooks calls RunHook for each of the given runtime hooks.
The given runtime state is serialized as JSON and passed to each RunHook call.
package specki
import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"time"
	"github.com/opencontainers/runtime-spec/specs-go"
)
func UnmapContainerID(id uint32, idmaps []specs.LinuxIDMapping) uint32 {
	for _, idmap := range idmaps {
		if idmap.Size < 1 {
			continue
		}
		maxID := idmap.ContainerID + idmap.Size - 1
		if (id >= idmap.ContainerID) && (id <= maxID) {
			offset := id - idmap.ContainerID
			hostid := idmap.HostID + offset
			return hostid
		}
	}
	return id
}