Skip to content

Commit

Permalink
Merge pull request firecracker-microvm#102 from superfly/expose-pid
Browse files Browse the repository at this point in the history
Expose machine's PID
  • Loading branch information
sipsma committed Jul 10, 2019
2 parents b2e8284 + 1458000 commit a585107
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ func (m *Machine) Logger() *log.Entry {
return m.logger.WithField("subsystem", userAgent)
}

// PID returns the machine's running process PID or an error if not running
func (m *Machine) PID() (int, error) {
if m.cmd == nil || m.cmd.Process == nil {
return 0, fmt.Errorf("machine is not running")
}
select {
case <-m.exitCh:
return 0, fmt.Errorf("machine process has exited")
default:
}
return m.cmd.Process.Pid, nil
}

// NetworkInterface represents a Firecracker microVM's network interface.
type NetworkInterface struct {
// MacAddress defines the MAC address that should be assigned to the network
Expand Down

0 comments on commit a585107

Please sign in to comment.