diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-06-29 11:58:22 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-06-29 11:58:22 +0200 |
| commit | ca1f32d15adf9329752047b4f9e1cebd9f52cd00 (patch) | |
| tree | 72fda9a695e2637acf4cbcaf457ca826e1b71cd0 /pkg/ipc | |
| parent | ac5f183dc06d92746de65883b4e06677dfbfd812 (diff) | |
pkg/ipc: cleanup binary copy
Diffstat (limited to 'pkg/ipc')
| -rw-r--r-- | pkg/ipc/ipc.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index ff49afd36..b25573483 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -170,12 +170,13 @@ type Env struct { in []byte out []byte - cmd *command - inFile *os.File - outFile *os.File - bin []string - pid int - config *Config + cmd *command + inFile *os.File + outFile *os.File + bin []string + linkedBin string + pid int + config *Config StatExecs uint64 StatRestarts uint64 @@ -241,6 +242,7 @@ func MakeEnv(config *Config, pid int) (*Env, error) { binCopy := filepath.Join(filepath.Dir(env.bin[0]), base+pidStr) if err := os.Link(env.bin[0], binCopy); err == nil { env.bin[0] = binCopy + env.linkedBin = binCopy } inf = nil outf = nil @@ -251,6 +253,9 @@ func (env *Env) Close() error { if env.cmd != nil { env.cmd.close() } + if env.linkedBin != "" { + os.Remove(env.linkedBin) + } var err1, err2 error if env.inFile != nil { err1 = osutil.CloseMemMappedFile(env.inFile, env.in) |
