mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
runsc: generate exec pidfile after everything is ready.
PiperOrigin-RevId: 221123160 Change-Id: Ia7061d60d114d69f49aba853fe6bae3c733522b5
This commit is contained in:
+9
-6
@@ -146,12 +146,6 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
|
||||
return ex.execAndWait(waitStatus)
|
||||
}
|
||||
|
||||
if ex.pidFile != "" {
|
||||
if err := ioutil.WriteFile(ex.pidFile, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
|
||||
Fatalf("error writing pid file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Start the new process and get it pid.
|
||||
pid, err := c.Execute(e)
|
||||
if err != nil {
|
||||
@@ -173,6 +167,15 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the pid file after the internal pid file is generated, so that users
|
||||
// can safely assume that the internal pid file is ready after `runsc exec -d`
|
||||
// returns.
|
||||
if ex.pidFile != "" {
|
||||
if err := ioutil.WriteFile(ex.pidFile, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
|
||||
Fatalf("error writing pid file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the process to exit.
|
||||
ws, err := c.WaitPID(pid, ex.clearStatus)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user