|
@@ -67,7 +67,12 @@ func (p *pipe) Write(b []byte) (int, error) {
|
|
// CreateProcessInComputeSystem starts a process in a container. This is invoked, for example,
|
|
// CreateProcessInComputeSystem starts a process in a container. This is invoked, for example,
|
|
// as a result of docker run, docker exec, or RUN in Dockerfile. If successful,
|
|
// as a result of docker run, docker exec, or RUN in Dockerfile. If successful,
|
|
// it returns the PID of the process.
|
|
// it returns the PID of the process.
|
|
-func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useStderr bool, params CreateProcessParams) (processid uint32, stdin io.WriteCloser, stdout io.ReadCloser, stderr io.ReadCloser, err error) {
|
|
|
|
|
|
+func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useStderr bool, params CreateProcessParams) (uint32, io.WriteCloser, io.ReadCloser, io.ReadCloser, uint32, error) {
|
|
|
|
+
|
|
|
|
+ var (
|
|
|
|
+ stdin io.WriteCloser
|
|
|
|
+ stdout, stderr io.ReadCloser
|
|
|
|
+ )
|
|
|
|
|
|
title := "HCSShim::CreateProcessInComputeSystem"
|
|
title := "HCSShim::CreateProcessInComputeSystem"
|
|
logrus.Debugf(title+" id=%s", id)
|
|
logrus.Debugf(title+" id=%s", id)
|
|
@@ -78,7 +83,7 @@ func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useS
|
|
defer dll.Release()
|
|
defer dll.Release()
|
|
}
|
|
}
|
|
if err != nil {
|
|
if err != nil {
|
|
- return
|
|
|
|
|
|
+ return 0, nil, nil, nil, 0xFFFFFFFF, err
|
|
}
|
|
}
|
|
|
|
|
|
// Convert id to uint16 pointer for calling the procedure
|
|
// Convert id to uint16 pointer for calling the procedure
|
|
@@ -86,7 +91,7 @@ func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useS
|
|
if err != nil {
|
|
if err != nil {
|
|
err = fmt.Errorf(title+" - Failed conversion of id %s to pointer %s", id, err)
|
|
err = fmt.Errorf(title+" - Failed conversion of id %s to pointer %s", id, err)
|
|
logrus.Error(err)
|
|
logrus.Error(err)
|
|
- return
|
|
|
|
|
|
+ return 0, nil, nil, nil, 0xFFFFFFFF, err
|
|
}
|
|
}
|
|
|
|
|
|
// If we are not emulating a console, ignore any console size passed to us
|
|
// If we are not emulating a console, ignore any console size passed to us
|
|
@@ -98,13 +103,13 @@ func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useS
|
|
paramsJson, err := json.Marshal(params)
|
|
paramsJson, err := json.Marshal(params)
|
|
if err != nil {
|
|
if err != nil {
|
|
err = fmt.Errorf(title+" - Failed to marshall params %v %s", params, err)
|
|
err = fmt.Errorf(title+" - Failed to marshall params %v %s", params, err)
|
|
- return
|
|
|
|
|
|
+ return 0, nil, nil, nil, 0xFFFFFFFF, err
|
|
}
|
|
}
|
|
|
|
|
|
// Convert paramsJson to uint16 pointer for calling the procedure
|
|
// Convert paramsJson to uint16 pointer for calling the procedure
|
|
paramsJsonp, err := syscall.UTF16PtrFromString(string(paramsJson))
|
|
paramsJsonp, err := syscall.UTF16PtrFromString(string(paramsJson))
|
|
if err != nil {
|
|
if err != nil {
|
|
- return
|
|
|
|
|
|
+ return 0, nil, nil, nil, 0xFFFFFFFF, err
|
|
}
|
|
}
|
|
|
|
|
|
// Get a POINTER to variable to take the pid outparm
|
|
// Get a POINTER to variable to take the pid outparm
|
|
@@ -138,8 +143,12 @@ func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useS
|
|
|
|
|
|
if r1 != 0 {
|
|
if r1 != 0 {
|
|
err = fmt.Errorf(title+" - Win32 API call returned error r1=%d err=%s id=%s params=%v", r1, syscall.Errno(r1), id, params)
|
|
err = fmt.Errorf(title+" - Win32 API call returned error r1=%d err=%s id=%s params=%v", r1, syscall.Errno(r1), id, params)
|
|
- logrus.Error(err)
|
|
|
|
- return
|
|
|
|
|
|
+ // Windows TP4: Hyper-V Containers may return this error with more than one
|
|
|
|
+ // concurrent exec. Do not log it as an error
|
|
|
|
+ if uint32(r1) != Win32InvalidArgument {
|
|
|
|
+ logrus.Error(err)
|
|
|
|
+ }
|
|
|
|
+ return 0, nil, nil, nil, uint32(r1), err
|
|
}
|
|
}
|
|
|
|
|
|
if useStdin {
|
|
if useStdin {
|
|
@@ -153,5 +162,5 @@ func CreateProcessInComputeSystem(id string, useStdin bool, useStdout bool, useS
|
|
}
|
|
}
|
|
|
|
|
|
logrus.Debugf(title+" - succeeded id=%s params=%s pid=%d", id, paramsJson, *pid)
|
|
logrus.Debugf(title+" - succeeded id=%s params=%s pid=%d", id, paramsJson, *pid)
|
|
- return *pid, stdin, stdout, stderr, nil
|
|
|
|
|
|
+ return *pid, stdin, stdout, stderr, 0, nil
|
|
}
|
|
}
|