@@ -268,20 +268,26 @@ func (p *setnsProcess) start() (retErr error) {
268268 }
269269 }
270270 }
271- // set rlimits, this has to be done here because we lose permissions
272- // to raise the limits once we enter a user-namespace
273- if err := setupRlimits (p .config .Rlimits , p .pid ()); err != nil {
274- return fmt .Errorf ("error setting rlimits for process: %w" , err )
275- }
271+
276272 if err := utils .WriteJSON (p .comm .initSockParent , p .config ); err != nil {
277273 return fmt .Errorf ("error writing config to pipe: %w" , err )
278274 }
279275
276+ var seenProcReady bool
280277 ierr := parseSync (p .comm .syncSockParent , func (sync * syncT ) error {
281278 switch sync .Type {
282279 case procReady :
283- // This shouldn't happen.
284- panic ("unexpected procReady in setns" )
280+ seenProcReady = true
281+ // Set rlimits, this has to be done here because we lose permissions
282+ // to raise the limits once we enter a user-namespace
283+ if err := setupRlimits (p .config .Rlimits , p .pid ()); err != nil {
284+ return fmt .Errorf ("error setting rlimits for ready process: %w" , err )
285+ }
286+
287+ // Sync with child.
288+ if err := writeSync (p .comm .syncSockParent , procRun ); err != nil {
289+ return err
290+ }
285291 case procHooks :
286292 // This shouldn't happen.
287293 panic ("unexpected procHooks in setns" )
@@ -340,6 +346,9 @@ func (p *setnsProcess) start() (retErr error) {
340346 if err := p .comm .syncSockParent .Shutdown (unix .SHUT_WR ); err != nil && ierr == nil {
341347 return err
342348 }
349+ if ! seenProcReady && ierr == nil {
350+ ierr = errors .New ("procReady not received" )
351+ }
343352 // Must be done after Shutdown so the child will exit and we can wait for it.
344353 if ierr != nil {
345354 _ , _ = p .wait ()
@@ -774,7 +783,7 @@ func (p *initProcess) start() (retErr error) {
774783 }
775784 case procReady :
776785 seenProcReady = true
777- // set rlimits, this has to be done here because we lose permissions
786+ // Set rlimits, this has to be done here because we lose permissions
778787 // to raise the limits once we enter a user-namespace
779788 if err := setupRlimits (p .config .Rlimits , p .pid ()); err != nil {
780789 return fmt .Errorf ("error setting rlimits for ready process: %w" , err )
0 commit comments