@@ -268,20 +268,26 @@ func (p *setnsProcess) start() (retErr error) {
268
268
}
269
269
}
270
270
}
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
+
276
272
if err := utils .WriteJSON (p .comm .initSockParent , p .config ); err != nil {
277
273
return fmt .Errorf ("error writing config to pipe: %w" , err )
278
274
}
279
275
276
+ var seenProcReady bool
280
277
ierr := parseSync (p .comm .syncSockParent , func (sync * syncT ) error {
281
278
switch sync .Type {
282
279
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
+ }
285
291
case procHooks :
286
292
// This shouldn't happen.
287
293
panic ("unexpected procHooks in setns" )
@@ -340,6 +346,9 @@ func (p *setnsProcess) start() (retErr error) {
340
346
if err := p .comm .syncSockParent .Shutdown (unix .SHUT_WR ); err != nil && ierr == nil {
341
347
return err
342
348
}
349
+ if ! seenProcReady && ierr == nil {
350
+ ierr = errors .New ("procReady not received" )
351
+ }
343
352
// Must be done after Shutdown so the child will exit and we can wait for it.
344
353
if ierr != nil {
345
354
_ , _ = p .wait ()
@@ -774,7 +783,7 @@ func (p *initProcess) start() (retErr error) {
774
783
}
775
784
case procReady :
776
785
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
778
787
// to raise the limits once we enter a user-namespace
779
788
if err := setupRlimits (p .config .Rlimits , p .pid ()); err != nil {
780
789
return fmt .Errorf ("error setting rlimits for ready process: %w" , err )
0 commit comments