not-enough-standards icon indicating copy to clipboard operation
not-enough-standards copied to clipboard

Add 'detached process' option

Open studoot opened this issue 1 year ago • 3 comments

I've recently had need of a detached process on Windows (i.e. it doesn't open a new console window) while using not-enough-standards.

I implemented this by adding a detached flag to process_options and processing it in the Windows implementation of the relevant process constructor (here's the commit in my fork).

This is a feature that I think Winows programmers would find useful and I'm quite happy to create a PR for this. I'm not sure that Linux has an equivalent need (I'm not particularly experienced with Linux, though), in which case detached would be a no-op. If you had other suggestions, please let me know.

studoot avatar Jul 28 '22 09:07 studoot

Hi studoot,

This may indeed be a useful feature, but I don't think "detached" is a good name for this process option because it will create ambiguity with the detach() function and the whole "join" concept, example:

nes::process proc{..., nes::process_options::detached};
//Do I need to call detach or join ? humm

Since it is not implementable on most other systems ("console app" is a windows only concept afaik), maybe we can add it as an extension and name it "win32_detached" or something that to relieve this ambiguity and clearly mark it as a platform specific feature. And if we do this then give it a higher value to prevent future potential enum conflict, like 0x01 << 24, where 24 could be the "platform-specific shift"

Alairion avatar Jul 30 '22 08:07 Alairion

Yes, that all sounds good - I'll implement those changes and create the PR.

studoot avatar Aug 13 '22 13:08 studoot

Qt calls it detached process too "QProcess::spawnDetached", and it also means that the process becomes the leader of its own process group (CREATE_NEW_PROCESS_GROUP on Windows, fork + setsid + posix_spawn on Posix).

SirLynix avatar Jan 24 '24 10:01 SirLynix