wget-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wget2 | Background support for Windows (#457)


From: Suhas K S
Subject: Re: wget2 | Background support for Windows (#457)
Date: Sat, 18 Jan 2020 18:28:39 +0000



Suhas K S commented:


I've found a way to implement the feature without `fork()` and by using just 
`CreateProcess()` from `WIN32`.

Instead of duplicating the current wget2 process using fork, `CreateProcess()` 
could be used to create a new wget2 process with the same options and 
parameters as used for the current running instance of wget2 but without 
`--background`.

For the new process to run in the background, `the DETACHED_PROCESS` creation 
flag can be used while calling `CreateProcess()` like so:

`if(!CreateProcess(NULL, Cmdline, NULL, NULL, 0, DETACHED_PROCESS, NULL, NULL, 
&si, &pi))`

The `DETACHED_PROCESS` flag ensures that the new process does not inherit its 
parent's console and runs independent of a console. The current running wget2 
process's command line args could be used to build the original command without 
`--background` as `Cmdline` and could be given to `CreateProcess()` as the 
`lpCommandLine`. After calling `CreateProcess()`, the parent process could 
exit, bringing back the shell.

I implemented this on a local build of wget2 and it works but is it a valid 
solution?

-- 
Reply to this email directly or view it on GitLab: 
https://gitlab.com/gnuwget/wget2/issues/457#note_273528448
You're receiving this email because of your account on gitlab.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]