@@ -141,24 +141,26 @@ func startInitialization() (retErr error) {
141141 logrus .SetLevel (logrus .Level (logLevel ))
142142 }
143143
144- logFD , err := strconv .Atoi (os .Getenv ("_LIBCONTAINER_LOGPIPE" ))
144+ logFd , err := strconv .Atoi (os .Getenv ("_LIBCONTAINER_LOGPIPE" ))
145145 if err != nil {
146146 return fmt .Errorf ("unable to convert _LIBCONTAINER_LOGPIPE: %w" , err )
147147 }
148+ logPipe := os .NewFile (uintptr (logFd ), "logpipe" )
148149
149- logrus .SetOutput (os . NewFile ( uintptr ( logFD ), "logpipe" ) )
150+ logrus .SetOutput (logPipe )
150151 logrus .SetFormatter (new (logrus.JSONFormatter ))
151152 logrus .Debug ("child process in init()" )
152153
153154 // Only init processes have FIFOFD.
154- fifofd := - 1
155+ var fifoFile * os. File
155156 envInitType := os .Getenv ("_LIBCONTAINER_INITTYPE" )
156157 it := initType (envInitType )
157158 if it == initStandard {
158- envFifoFd := os .Getenv ("_LIBCONTAINER_FIFOFD" )
159- if fifofd , err = strconv . Atoi ( envFifoFd ); err != nil {
159+ fifoFd , err := strconv . Atoi ( os .Getenv ("_LIBCONTAINER_FIFOFD" ) )
160+ if err != nil {
160161 return fmt .Errorf ("unable to convert _LIBCONTAINER_FIFOFD: %w" , err )
161162 }
163+ fifoFile = os .NewFile (uintptr (fifoFd ), "initfifo" )
162164 }
163165
164166 var consoleSocket * os.File
@@ -212,10 +214,10 @@ func startInitialization() (retErr error) {
212214 }
213215
214216 // If init succeeds, it will not return, hence none of the defers will be called.
215- return containerInit (it , & config , syncPipe , consoleSocket , pidfdSocket , fifofd , logFD , dmzExe )
217+ return containerInit (it , & config , syncPipe , consoleSocket , pidfdSocket , fifoFile , logPipe , dmzExe )
216218}
217219
218- func containerInit (t initType , config * initConfig , pipe * syncSocket , consoleSocket , pidfdSocket * os. File , fifoFd , logFd int , dmzExe * os.File ) error {
220+ func containerInit (t initType , config * initConfig , pipe * syncSocket , consoleSocket , pidfdSocket , fifoFile , logPipe , dmzExe * os.File ) error {
219221 if err := populateProcessEnvironment (config .Env ); err != nil {
220222 return err
221223 }
@@ -227,7 +229,7 @@ func containerInit(t initType, config *initConfig, pipe *syncSocket, consoleSock
227229 consoleSocket : consoleSocket ,
228230 pidfdSocket : pidfdSocket ,
229231 config : config ,
230- logFd : logFd ,
232+ logPipe : logPipe ,
231233 dmzExe : dmzExe ,
232234 }
233235 return i .Init ()
@@ -238,8 +240,8 @@ func containerInit(t initType, config *initConfig, pipe *syncSocket, consoleSock
238240 pidfdSocket : pidfdSocket ,
239241 parentPid : unix .Getppid (),
240242 config : config ,
241- fifoFd : fifoFd ,
242- logFd : logFd ,
243+ fifoFile : fifoFile ,
244+ logPipe : logPipe ,
243245 dmzExe : dmzExe ,
244246 }
245247 return i .Init ()
0 commit comments