Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #933 (closed enhancement: fixed)

Opened 7 months ago

Last modified 7 months ago

Process.execute opens new console

Reported by: torhu Assigned to: schveiguy
Priority: major Milestone: 0.99.5
Component: Core Functionality Version: trunk
Keywords: Cc: torhu@yahoo.com

Description

I'm using svn 3188.

When I start a child process from a gui app, a new console is created. I'm guessing that this was caused by DETACHED_PROCESS being removed in r3178. But I haven't verified it.

Before using tango for this task, I was using Regan Heath process.d and pipestream.d. The only difference I can see is DETACHED_PROCESS not being used in tango.

I don't know the quirks of CreateProcess?, but maybe the CREATE_NO_WINDOW flag would help? If it doesn't work, I think having batch files work properly is secondary to having exes work.

Change History

02/20/08 05:46:08 changed by torhu

  • owner changed from sean to schveiguy.

02/20/08 08:08:29 changed by schveiguy

  • status changed from new to assigned.
  • type changed from defect to enhancement.
  • milestone changed from 0.99.6 to 1.0.

The issue is that you are starting console applications, and the OS allocates a console for you if there is not one already. If you are starting GUI applications the console should not appear. This is consistent with starting a console application from Explorer, and is considered to be default behavior. Having a window pop up is cosmetic, not being able to redirect output is loss of functionality.

I have not tried the CREATE_NO_WINDOW flag, but I cannot tell from the documentation that it is any different from DETACHED_PROCESS. I looked at the documentation and researched online for a while to figure out if it was any different. I will try it out to see if it helps.

I'm looking at enhancing process to be able to specify whether stdout/stderr/stdin should be redirected, perhaps we could include a no_window flag that does nothing on posix systems?

02/20/08 08:10:12 changed by schveiguy

The ehancement proposal for optionally redirecting output is #718

02/20/08 23:01:55 changed by torhu

I tried reading the stdout of a batch file when using DETACHED_PROCESS, and it works for me. I also did some tests with CREATE_NO_WINDOW, but I couldn't see any differences from using DETACHED_PROCESS. Batch files and exes work just fine in both cases. With zero for the flag, console windows are created for both batch files and exes, when run from a subsystem:windows app.

I only tried stdout, not stderr or stdin. I didn't use tango, but regan heath's stuff and phobos. Should work the same, though.

02/20/08 23:02:25 changed by torhu

  • cc set to torhu@yahoo.com.

02/21/08 01:22:14 changed by schveiguy

Hm.. did you try running a console-based process in that batch file? My test was a batch file that runs diskpart /?, and I did not get output from stdout.

02/21/08 13:40:05 changed by schveiguy

  • milestone changed from 1.0 to 0.99.6.

02/21/08 13:40:17 changed by schveiguy

  • milestone changed from 0.99.6 to 0.99.5.

02/21/08 13:40:46 changed by schveiguy

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [3237]) Changed flag for creating process to CREATE_NO_WINDOW, which appears to have the best of both worlds (does not flash a console window, and allows redirection of stdout/err for batch files).

This flag isn't supported on Windows 95/98/Me, but I don't think that really matters much these days.

fixes #933