1

I'm writing a handful of tools that I'd like to on Windows. They're generally "command shims", i.e. they do some work once and then execute another program using one of the functions in the exec family in Unix.

An example would be setting a bunch of environment variables like shush. It can be used like:

export KMS_ENCRYPTED_MOO=<base64str...> shush exec -- env

The shush program iterates over env vars, decrypts variables that have the prefix KMS_ENCRYPTED_ using AWS KMS and sets new environment variables (sans prefix) with the decrypted value before continuing execution of the env program.

How can I do this on Windows? My understanding is that Windows' CreateProcess function is equivalent to a fused fork and exec pair on *nix, but I only want the functionality of the latter. I know I could create a child process and forward stdin, stdout and stderr to the child process, but then I'd also have to handle whatever Windows' equivalent of signals are and that seems fraught with danger for a novice like me.

Aidan Steele
  • 10,999
  • 6
  • 38
  • 59

1 Answers1

1

Just my luck. I've been googling this on and off for weeks to no avail and as soon as I post this question I manage to stumble across what seems to do the trick:

CreateProcess usage for executable wrapper for Windows?

Is this sufficient to handle any "signals" and whatnot? Any edge-cases that I should be aware of? I guess I would need to wait for the child to terminate before self-terminating and pass through the exit code - anything else?

Community
  • 1
  • 1
Aidan Steele
  • 10,999
  • 6
  • 38
  • 59