1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: add create_no_window parameter to Process (#17726)

This commit is contained in:
d3c0d3d.exe 2023-03-21 06:24:40 -03:00 committed by GitHub
parent e1d4539a14
commit 54a1b66b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View File

@ -25,14 +25,15 @@ pub mut:
// the exit code of the process, != -1 *only* when status is .exited *and* the process was not aborted
status ProcessState = .not_started
// the current status of the process
err string // if the process fails, contains the reason why
args []string // the arguments that the command takes
env_is_custom bool // true, when the environment was customized with .set_environment
env []string // the environment with which the process was started (list of 'var=val')
use_stdio_ctl bool // when true, then you can use p.stdin_write(), p.stdout_slurp() and p.stderr_slurp()
use_pgroup bool // when true, the process will create a new process group, enabling .signal_pgkill()
stdio_fd [3]int // the stdio file descriptors for the child process, used only by the nix implementation
wdata voidptr // the WProcess; used only by the windows implementation
err string // if the process fails, contains the reason why
args []string // the arguments that the command takes
env_is_custom bool // true, when the environment was customized with .set_environment
env []string // the environment with which the process was started (list of 'var=val')
use_stdio_ctl bool // when true, then you can use p.stdin_write(), p.stdout_slurp() and p.stderr_slurp()
use_pgroup bool // when true, the process will create a new process group, enabling .signal_pgkill()
stdio_fd [3]int // the stdio file descriptors for the child process, used only by the nix implementation
wdata voidptr // the WProcess; used only by the windows implementation
create_no_window bool // sets a value indicating whether to start the process in a new window, The default is false; used only by the windows implementation
}
// new_process - create a new process descriptor

View File

@ -97,7 +97,11 @@ fn (mut p Process) win_spawn_process() int {
cmd := '${p.filename} ' + p.args.join(' ')
C.ExpandEnvironmentStringsW(cmd.to_wide(), voidptr(&wdata.command_line[0]), 32768)
mut creation_flags := int(C.NORMAL_PRIORITY_CLASS)
mut creation_flags := if p.create_no_window {
int(C.CREATE_NO_WINDOW)
} else {
int(C.NORMAL_PRIORITY_CLASS)
}
if p.use_pgroup {
creation_flags |= C.CREATE_NEW_PROCESS_GROUP
}