Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: don't use clone flags to start shim
Browse files Browse the repository at this point in the history
shim is already started in a new namespace, hence it doesn't need
the clone flags to create a new namespace.

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Oct 19, 2018
1 parent 4649c9e commit 2af4315
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions virtcontainers/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,6 @@ func startShim(args []string, params ShimParams) (int, error) {
cmd.Stderr = os.Stderr
}

cloneFlags := 0
for _, nsType := range params.CreateNS {
cloneFlags |= ns.CloneFlagsTable[nsType]
}

cmd.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: uintptr(cloneFlags),
}

var f *os.File
var err error
if params.Console != "" {
Expand All @@ -211,21 +202,21 @@ func startShim(args []string, params ShimParams) (int, error) {
cmd.Stdin = f
cmd.Stdout = f
cmd.Stderr = f
// Create Session
cmd.SysProcAttr.Setsid = true
// Set Controlling terminal to Ctty
cmd.SysProcAttr.Setctty = true
cmd.SysProcAttr.Ctty = int(f.Fd())
cmd.SysProcAttr = &syscall.SysProcAttr{
// Create Session
Setsid: true,
// Set Controlling terminal to Ctty
Setctty: true,
Ctty: int(f.Fd()),
}
}
defer func() {
if f != nil {
f.Close()
}
}()

if err := ns.NsEnter(params.EnterNS, func() error {
return cmd.Start()
}); err != nil {
if err := cmd.Start(); err != nil {
return -1, err
}

Expand Down

0 comments on commit 2af4315

Please sign in to comment.