Created
June 26, 2019 11:36
-
-
Save aoleg94/337fbab219a91648a7d0d162e5a768ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <spawn.h> | |
#include <sys/wait.h> | |
int main(int argc, char** argv, char** envp) | |
{ | |
if(argc < 2) | |
{ | |
SetThreadExecutionState(ES_SYSTEM_REQUIRED); | |
return 0; | |
} | |
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED); | |
pid_t p = -1; | |
int ret = posix_spawnp(&p, argv[1], 0, 0, argv+1, envp); | |
if(!ret) | |
{ | |
int ws = 0; | |
waitpid(p, &ws, 0); | |
ret = WEXITSTATUS(ws); | |
} | |
SetThreadExecutionState(ES_CONTINUOUS); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment