@@ -137,24 +137,26 @@ func startInitialization() (retErr error) {
137137 logrus .SetLevel (logrus .Level (logLevel ))
138138 }
139139
140- logFD , err := strconv .Atoi (os .Getenv ("_LIBCONTAINER_LOGPIPE" ))
140+ logFd , err := strconv .Atoi (os .Getenv ("_LIBCONTAINER_LOGPIPE" ))
141141 if err != nil {
142142 return fmt .Errorf ("unable to convert _LIBCONTAINER_LOGPIPE: %w" , err )
143143 }
144+ logPipe := os .NewFile (uintptr (logFd ), "logpipe" )
144145
145- logrus .SetOutput (os . NewFile ( uintptr ( logFD ), "logpipe" ) )
146+ logrus .SetOutput (logPipe )
146147 logrus .SetFormatter (new (logrus.JSONFormatter ))
147148 logrus .Debug ("child process in init()" )
148149
149150 // Only init processes have FIFOFD.
150- fifofd := - 1
151+ var fifoFile * os. File
151152 envInitType := os .Getenv ("_LIBCONTAINER_INITTYPE" )
152153 it := initType (envInitType )
153154 if it == initStandard {
154- envFifoFd := os .Getenv ("_LIBCONTAINER_FIFOFD" )
155- if fifofd , err = strconv . Atoi ( envFifoFd ); err != nil {
155+ fifoFd , err := strconv . Atoi ( os .Getenv ("_LIBCONTAINER_FIFOFD" ) )
156+ if err != nil {
156157 return fmt .Errorf ("unable to convert _LIBCONTAINER_FIFOFD: %w" , err )
157158 }
159+ fifoFile = os .NewFile (uintptr (fifoFd ), "initfifo" )
158160 }
159161
160162 var consoleSocket * os.File
@@ -208,10 +210,10 @@ func startInitialization() (retErr error) {
208210 }
209211
210212 // If init succeeds, it will not return, hence none of the defers will be called.
211- return containerInit (it , & config , syncPipe , consoleSocket , pidfdSocket , fifofd , logFD , dmzExe )
213+ return containerInit (it , & config , syncPipe , consoleSocket , pidfdSocket , fifoFile , logPipe , dmzExe )
212214}
213215
214- func containerInit (t initType , config * initConfig , pipe * syncSocket , consoleSocket , pidfdSocket * os. File , fifoFd , logFd int , dmzExe * os.File ) error {
216+ func containerInit (t initType , config * initConfig , pipe * syncSocket , consoleSocket , pidfdSocket , fifoFile , logPipe , dmzExe * os.File ) error {
215217 if err := populateProcessEnvironment (config .Env ); err != nil {
216218 return err
217219 }
@@ -223,7 +225,7 @@ func containerInit(t initType, config *initConfig, pipe *syncSocket, consoleSock
223225 consoleSocket : consoleSocket ,
224226 pidfdSocket : pidfdSocket ,
225227 config : config ,
226- logFd : logFd ,
228+ logPipe : logPipe ,
227229 dmzExe : dmzExe ,
228230 }
229231 return i .Init ()
@@ -234,8 +236,8 @@ func containerInit(t initType, config *initConfig, pipe *syncSocket, consoleSock
234236 pidfdSocket : pidfdSocket ,
235237 parentPid : unix .Getppid (),
236238 config : config ,
237- fifoFd : fifoFd ,
238- logFd : logFd ,
239+ fifoFile : fifoFile ,
240+ logPipe : logPipe ,
239241 dmzExe : dmzExe ,
240242 }
241243 return i .Init ()
0 commit comments