sheredom / subprocess.h

🐜 single header process launching solution for C and C++
The Unlicense
1.1k stars 97 forks source link

Lib is not spawning terminal instance to run a code #48

Closed flamendless closed 3 years ago

flamendless commented 3 years ago

previously im doing this to launch a C++ bin in a separate terminal in linux:

    std::string cmd_linux = fmt::format("$TERMINAL -e \"./{:s}\"", filename);
    FILE* p = popen(cmd_linux.c_str(), "r");
    if (p == NULL)
        return RES_FAIL;
    pclose(p);

but converting it to using subprocess works in that it doesnt throw any error, but there's nothing ran.

    const char* cmd_linux[] = {filename.c_str(), NULL};
    //const char* cmd_linux[] = {"$TERMINAL", "-e", filename.c_str(), NULL}; //doesnt even work
    struct subprocess_s subprocess;
    int result = subprocess_create(cmd_linux, subprocess_option_inherit_environment, &subprocess);
    if (result != 0)
        return RES_FAIL;

the file to be ran is in the same directory as the program. The program to run has a getchar() at then end so it wont close automatically

sheredom commented 3 years ago

I'm pretty sure that my thing won't know what $TERMINAL is to run it.