Skip to content

win: possible regression related to UV_PROCESS_WINDOWS_HIDE change #1625

Closed

Description

@ugexe

Here is a before/after of win: let UV_PROCESS_WINDOWS_HIDE hide consoles via identical commits of MoarVM/Perl6 on Win10, where we can notice a change in how an inherited handle works:

before (output of child is seen)
C:\Users\nloga\foo>perl6 -e "my $proc = Proc::Async.new('cmd.exe','/c','dir'); my $promise = $proc.start; await $promise; say 'done'; say $promise.result"
 Volume in drive C has no label.
 Volume Serial Number is 22C4-E412

 Directory of C:\Users\nloga\foo

11/10/2017  02:40 PM    <DIR>          .
11/10/2017  02:40 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  32,038,256,640 bytes free
done
Proc.new(in => IO::Pipe, out => IO::Pipe, err => IO::Pipe, exitcode => 0, signal => 0, command => ["cmd.exe", "/c", "dir"])
after (output of child is -not- seen)
C:\Users\nloga\foo>perl6 -e "my $proc = Proc::Async.new('cmd.exe','/c','dir'); my $promise = $proc.start; await $promise; say 'done'; say $promise.result"
done
Proc.new(in => IO::Pipe, out => IO::Pipe, err => IO::Pipe, exitcode => 0, signal => 0, command => ["cmd.exe", "/c", "dir"])

irc discussion

It is possible MoarMV/src/io/procops.c#L629 could be doing something wrong with UV_INHERIT_FD, but I'm not sure how to determine this (and hence give you a more pure example).


This hints that additional checks may be needed somewhere:

    if (sInfo.hStdInput  != GetStdHandle(STD_INPUT_HANDLE)  &&
        sInfo.hStdOutput != GetStdHandle(STD_OUTPUT_HANDLE) &&
        sInfo.hStdError  != GetStdHandle(STD_ERROR_HANDLE)  &&
        (flags & RUN_PROCESS_IN_NEW_GROUP) == 0)
            dwFlags |= CREATE_NO_WINDOW;   // Run without console window only when both output and error are redirected

Activity

  1. bnoordhuis commented on Nov 13, 2017

    @bnoordhuis
    Member

    @bzoz @cjihrig Ideas? I don't have any. No regressions have been reported against Node.js, to the best of my knowledge.

    edit: forgot to mention, MoarVM's code looks correct to me.

  2. cjihrig commented on Nov 13, 2017

    @cjihrig
    Contributor

    I'm not really sure either. Microsoft's documentation for the different flags isn't very good in this case. I don't recall any Node issues either, and IIRC, this is what Electron has been doing for a while now.

  3. ugexe commented on Nov 13, 2017

    @ugexe
    ContributorAuthor

    The flag was just added to Node (whereas it was already in use by MoarVM), so Node cannot expose a regression here can it?

  4. bnoordhuis commented on Nov 13, 2017

    @bnoordhuis
    Member

    No, but we'd probably have had a report by now if the new flag caused the behavior you describe in node.

  5. added a commit that references this issue on Nov 13, 2017
    dc4fac6
  6. ugexe commented on Nov 14, 2017

    @ugexe
    ContributorAuthor

    My current theory is electron had this problem before but later fixed it with additional logic not present in libuv:

    https://github.com/electron/electron/blob/c2ab4f711f500cb6b6caa4ce587942763c9cb0d0/atom/app/atom_main.cc#L84-L86

    which seems plausible given:

    CREATE_NO_WINDOW (0x08000000)
    The process is a console application that is being run without a console window. Therefore, the console handle for the application is not set.


    RouteStdioToConsole()
    Similar issue leading back to RouteStdioToConsole()

  7. ugexe commented on Nov 18, 2017

    @ugexe
    ContributorAuthor

    I believe I can show a regression in nodejs:


    windows (windowsHide = true) : deadlocks

    node -e "const cp = require('child_process'); { const bat = cp.spawn('cmd.exe', ['/k', 'dir'], { stdio: 'inherit', detached: false, windowsHide: true }); }"
    

    windows (windowsHide = false) : outputs directory contents

    node -e "const cp = require('child_process'); { const bat = cp.spawn('cmd.exe', ['/k', 'dir'], { stdio: 'inherit', detached: false, windowsHide: false }); }"
    

    osx/linux (windowsHide = true) : outputs directory contents

    node -e 'const cp = require("child_process"); { const bat = cp.spawn("ls", [], { stdio: "inherit", detached: false, windowsHide: true }); }'
    

  8. added 2 commits that reference this issue on Nov 30, 2017
    9161e21
    f1428d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions