github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/testutil/testutil_plan9.go (about)

     1  // Copyright 2020 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package testutil
     6  
     7  import (
     8  	"fmt"
     9  	"os/exec"
    10  	"syscall"
    11  )
    12  
    13  func exitStatus(exitErr *exec.ExitError) (int, error) {
    14  	ws, ok := exitErr.Sys().(syscall.Waitmsg)
    15  	if !ok {
    16  		return 0, fmt.Errorf("sys() is not a syscall Waitmsg: %v", exitErr)
    17  	}
    18  	return ws.ExitStatus(), nil
    19  }