From ca1f32d15adf9329752047b4f9e1cebd9f52cd00 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 29 Jun 2018 11:58:22 +0200 Subject: pkg/ipc: cleanup binary copy --- pkg/ipc/ipc.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'pkg/ipc') 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) -- cgit mrf-deployment