@@ -263,7 +263,7 @@ func main() {
263
263
return
264
264
}
265
265
266
- log .Debug ("Cleaning ..." )
266
+ log .Debug ("Exiting properly ..." )
267
267
}
268
268
269
269
func execCmd (cmdString string ) error {
@@ -287,14 +287,13 @@ func execCmd(cmdString string) error {
287
287
return err
288
288
}
289
289
290
- // TODO: There seems to be a problem if a Signal is catched, stdin is not
291
- // printed anymore on the terminal. A `reset` is needed
292
- stdin := os .Stdin
293
-
294
290
// Pass stdin / stdout / stderr as proc attributes
295
291
procAttr := os.ProcAttr {
296
- Files : []* os.File {stdin , os .Stdout , os .Stderr },
292
+ Files : []* os.File {os . Stdin , os .Stdout , os .Stderr },
297
293
Dir : pwd ,
294
+ Sys : & syscall.SysProcAttr {
295
+ Setpgid : true ,
296
+ },
298
297
}
299
298
300
299
log .Debugf ("Going to run `%s ( %s ) %s`" , cmdElmnts [0 ], bin , strings .Join (cmdElmnts [1 :], " " ))
@@ -314,7 +313,6 @@ func execCmd(cmdString string) error {
314
313
if err != nil {
315
314
log .Warn ("Failed to change the namespace: " , err )
316
315
}
317
- stdin .Close ()
318
316
319
317
// If there is a process, need to kill it
320
318
if proc != nil {
@@ -328,20 +326,6 @@ func execCmd(cmdString string) error {
328
326
} else {
329
327
log .Debugf ("No process to kill" )
330
328
}
331
-
332
- // If there is a namespace, need to delete it
333
- if namespace != nil {
334
- log .Debugf ("Deleting the namespace" )
335
- err := deleteNS (namespace )
336
- if err != nil {
337
- log .Warnf ("error while deleting namespace" , err )
338
- } else {
339
- log .Debugf ("Namespace deleted" )
340
- }
341
- } else {
342
- log .Debugf ("No namespace to delete" )
343
- }
344
- os .Exit (1 )
345
329
}()
346
330
347
331
// Start the process
@@ -359,7 +343,6 @@ func execCmd(cmdString string) error {
359
343
}
360
344
361
345
log .Debugf ("Result : %s" , state )
362
- stdin .Close ()
363
346
364
347
return nil
365
348
}
@@ -415,6 +398,8 @@ func getOriginalNS() (*netns.NsHandle, error) {
415
398
416
399
// deleteNS will delete the given namespace
417
400
func deleteNS (ns * netns.NsHandle ) error {
401
+ log .Debugf ("Deleting namespace" )
402
+
418
403
// Close the nsHandler
419
404
err := ns .Close ()
420
405
if err != nil {
0 commit comments