You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Alex Clemmer <cl...@gmail.com> on 2016/04/24 01:40:56 UTC

Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46608/
-----------------------------------------------------------

Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun.


Repository: mesos


Description
-------

Libprocess: Implemented `subprocess_windows.cpp`.


Diffs
-----

  3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46608/diff/


Testing
-------


Thanks,

Alex Clemmer


Re: Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`.

Posted by Michael Park <mp...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46608/#review131235
-----------------------------------------------------------




3rdparty/libprocess/src/subprocess_windows.cpp (lines 305 - 352)
<https://reviews.apache.org/r/46608/#comment195141>

    (1) According to the "Security Remarks" section of https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx, it's recommended that we set the `lpApplicationName` parameter, rather than embedding the module name inside the `lpCommandLine` parameter since we need to make sure that the modulen name in `lpCommandLine` needs to be wrapped in quotes in case of spaces in the name. We don't seem to be doing this correctly.
    
    (2) `argumentsEscaped` is `new`ed, but not `delete`d, and according to the documentation for `CreateProcess`, it does not call `delete` on `lpCommandLine`. It looks like we're leaking?
    
    (3) Are we required to escape the quotes like we're doing here for `argumentsEscaped`...? I don't see anything like this in the documentation.
    
    What I would prefer to do here I think is to take a `argv` by value, then do:
    
    ```cpp
    string program = argv[0];
    argv.erase(argv.begin());
    string args = strings::join(" ", argv);
    
    ... = CreateProcess(
      program.data(),
      args.data(),
      ...);
    ```
    
    If we wanted to avoid using `lpApplicationName` for whatever reason, how about:
    
    ```cpp
    string program = "\"" + argv[0] + "\"";
    argv.erase(argv.begin());
    string args = strings::join(" ", argv);
    string cmd = strings::join(" ", program, args);
    
    ... = CreateProcess(
      NULL,
      cmd.data(),
      ...);
    ```


- Michael Park


On April 23, 2016, 11:41 p.m., Alex Clemmer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46608/
> -----------------------------------------------------------
> 
> (Updated April 23, 2016, 11:41 p.m.)
> 
> 
> Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun.
> 
> 
> Bugs: MESOS-3637
>     https://issues.apache.org/jira/browse/MESOS-3637
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Libprocess: Implemented `subprocess_windows.cpp`.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46608/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Alex Clemmer
> 
>


Re: Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`.

Posted by Michael Park <mp...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46608/#review130974
-----------------------------------------------------------




3rdparty/libprocess/src/subprocess_windows.cpp (lines 534 - 539)
<https://reviews.apache.org/r/46608/#comment194941>

    A few comments here.
    
    (1) I think we can simply this to:
    
    ```
    string env;
    foreach (const string& key, const string& value, environment.get()) {
      env += key + '=' + value + '\0';
    }
    ```
    
    then pass `env.data()` to `createChildProcess`.
    
    (2) Currently, if the string is larger than 32767 bytes, `createProcessEnvironment` returns `NULL`. We subsequently pass that result to `createChildProcess`, which result in the following behavior:
    
    > lpEnvironment [in, optional]
    A pointer to the environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.
    
    Is this what we want? I think we can definitely incorporate whatever behavior we need if we go beyond the 32767 bytes, but I'm not sure exactly what behavior is expected here.


- Michael Park


On April 23, 2016, 11:41 p.m., Alex Clemmer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46608/
> -----------------------------------------------------------
> 
> (Updated April 23, 2016, 11:41 p.m.)
> 
> 
> Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun.
> 
> 
> Bugs: MESOS-3637
>     https://issues.apache.org/jira/browse/MESOS-3637
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Libprocess: Implemented `subprocess_windows.cpp`.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46608/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Alex Clemmer
> 
>


Re: Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`.

Posted by Michael Park <mp...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46608/#review130682
-----------------------------------------------------------




3rdparty/libprocess/src/subprocess_windows.cpp (line 77)
<https://reviews.apache.org/r/46608/#comment194535>

    Indent 2 spaces.



3rdparty/libprocess/src/subprocess_windows.cpp (line 79)
<https://reviews.apache.org/r/46608/#comment194537>

    `s/foreach(/foreach (/`



3rdparty/libprocess/src/subprocess_windows.cpp (line 153)
<https://reviews.apache.org/r/46608/#comment194534>

    Shouldn't we just `return duplicate;` here? Falling through and "leveraging" the `return handle` on the next line seems like a bad pattern to set.


- Michael Park


On April 23, 2016, 11:41 p.m., Alex Clemmer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46608/
> -----------------------------------------------------------
> 
> (Updated April 23, 2016, 11:41 p.m.)
> 
> 
> Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun.
> 
> 
> Bugs: MESOS-3637
>     https://issues.apache.org/jira/browse/MESOS-3637
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Libprocess: Implemented `subprocess_windows.cpp`.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46608/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Alex Clemmer
> 
>


Re: Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`.

Posted by Daniel Pravat <dp...@outlook.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46608/#review130852
-----------------------------------------------------------




3rdparty/libprocess/src/subprocess_windows.cpp (line 348)
<https://reviews.apache.org/r/46608/#comment194756>

    This is not requered in the current codebase.



3rdparty/libprocess/src/subprocess_windows.cpp (line 606)
<https://reviews.apache.org/r/46608/#comment194759>

    Since the process is not in suspended there is no need to resume here.



3rdparty/libprocess/src/subprocess_windows.cpp (line 607)
<https://reviews.apache.org/r/46608/#comment194760>

    The handle for the thread can be closed in the createChildProcess()


- Daniel Pravat


On April 23, 2016, 11:41 p.m., Alex Clemmer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46608/
> -----------------------------------------------------------
> 
> (Updated April 23, 2016, 11:41 p.m.)
> 
> 
> Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun.
> 
> 
> Bugs: MESOS-3637
>     https://issues.apache.org/jira/browse/MESOS-3637
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Libprocess: Implemented `subprocess_windows.cpp`.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46608/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Alex Clemmer
> 
>


Re: Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`.

Posted by Alex Clemmer <cl...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46608/
-----------------------------------------------------------

(Updated April 23, 2016, 11:41 p.m.)


Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun.


Bugs: MESOS-3637
    https://issues.apache.org/jira/browse/MESOS-3637


Repository: mesos


Description
-------

Libprocess: Implemented `subprocess_windows.cpp`.


Diffs
-----

  3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46608/diff/


Testing
-------


Thanks,

Alex Clemmer