Skip to content

Commit a1cfb79

Browse files
committed
expose machine.PID
1 parent b2e8284 commit a1cfb79

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

machine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ func (m *Machine) Logger() *log.Entry {
163163
return m.logger.WithField("subsystem", userAgent)
164164
}
165165

166+
// PID returns the machine's running process PID or an error if not running
167+
func (m *Machine) PID() (int, error) {
168+
if m.cmd == nil || m.cmd.Process == nil {
169+
return 0, fmt.Errorf("machine is not running")
170+
}
171+
return m.cmd.Process.Pid, nil
172+
}
173+
166174
// NetworkInterface represents a Firecracker microVM's network interface.
167175
type NetworkInterface struct {
168176
// MacAddress defines the MAC address that should be assigned to the network

0 commit comments

Comments
 (0)