Skip to content

Commit 85710ce

Browse files
alex-ilinmrjbq7
authored andcommitted
io.launcher: add the hidden slot to the process tuple
Implemented on Windows only.
1 parent 73c153f commit 85710ce

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

basis/io/launcher/launcher-docs.factor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ ARTICLE: "io.launcher.detached" "Running processes in the background"
1111
"By default, " { $link run-process } " waits for the process to complete. To run a process without waiting for it to finish, set the " { $snippet "detached" } " slot of a " { $link process } ", or use the following word:"
1212
{ $subsections run-detached } ;
1313

14+
ARTICLE: "io.launcher.hidden" "Running hidden processes"
15+
"By default, child processes can create and display their own (console and other) windows. To signal to a process that it should stay hidden, set the " { $snippet "hidden" } " slot of the " { $link process } " before running it. The processes are free to ignore this signal." ;
16+
1417
ARTICLE: "io.launcher.environment" "Setting environment variables"
1518
"The " { $snippet "environment" } " slot of a " { $link process } " contains an association mapping environment variable names to values. The interpretation of environment variables is operating system-specific."
1619
$nl
@@ -338,6 +341,7 @@ ARTICLE: "io.launcher" "Operating system processes"
338341
"io.launcher.lifecycle"
339342
"io.launcher.command"
340343
"io.launcher.detached"
344+
"io.launcher.hidden"
341345
"io.launcher.environment"
342346
"io.launcher.redirection"
343347
"io.launcher.priority"

basis/io/launcher/launcher.factor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ TUPLE: process < identity-tuple
1313

1414
command
1515
detached
16+
hidden
1617

1718
environment
1819
environment-mode

basis/io/launcher/windows/windows.factor

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
! Copyright (C) 2007, 2010 Doug Coleman, Slava Pestov.
22
! See http://factorcode.org/license.txt for BSD license.
33
USING: accessors alien alien.c-types alien.data arrays assocs
4-
classes classes.struct combinators concurrency.flags
5-
continuations debugger destructors init io io.backend
6-
io.backend.windows io.files io.files.private io.files.windows
7-
io.launcher io.launcher.private io.pathnames io.pipes
8-
io.pipes.windows io.ports kernel libc locals make math
9-
namespaces prettyprint sequences specialized-arrays splitting
10-
splitting.monotonic strings system threads windows
4+
classes classes.struct combinators combinators.short-circuit
5+
concurrency.flags continuations debugger destructors init io
6+
io.backend io.backend.windows io.files io.files.private
7+
io.files.windows io.launcher io.launcher.private io.pathnames
8+
io.pipes io.pipes.windows io.ports kernel libc literals locals
9+
make math namespaces prettyprint sequences specialized-arrays
10+
splitting splitting.monotonic strings system threads windows
1111
windows.errors windows.handles windows.kernel32 windows.types
12-
combinators.short-circuit ;
12+
windows.user32 ;
1313
SPECIALIZED-ARRAY: ushort
1414
SPECIALIZED-ARRAY: void*
1515
IN: io.launcher.windows
@@ -123,7 +123,13 @@ TUPLE: CreateProcess-args
123123
] when ;
124124

125125
: fill-startup-info ( process args -- process args )
126-
dup lpStartupInfo>> STARTF_USESTDHANDLES >>dwFlags drop ;
126+
over hidden>> [ dup lpStartupInfo>> ] dip
127+
[
128+
flags{ STARTF_USESTDHANDLES STARTF_USESHOWWINDOW } >>dwFlags
129+
SW_HIDE >>wShowWindow
130+
] [
131+
STARTF_USESTDHANDLES >>dwFlags
132+
] if drop ;
127133

128134
: make-CreateProcess-args ( process -- args )
129135
default-CreateProcess-args

0 commit comments

Comments
 (0)