I forgot to edit my comment to add that, for some reason, it doesn’t seem work on macOS. But if that’s not a problem for you, then I’m happy I could help.
Edit: I just read the code, and it seems like you found out about that before I could warn you. :)
I didn't know actually, I only did it so that it would also compile on Windows (which I haven't tested yet tbh). Good to know it would still compile on macOS
I want to note that you can call actual C functions from D without much extra effort.
Here’s a program that calls getpass: https://glot.io/snippets/fqf04b6wg2