Created
October 18, 2023 12:36
-
-
Save Hamayama/d0658e363bccda68af4b803ce4bbd529 to your computer and use it in GitHub Desktop.
Windows の _execvp() の実行サンプル
This file contains 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
@set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\bin;%PATH% | |
set MSYSTEM=MINGW64 | |
for %%i in ( | |
inout execvp | |
) do ( | |
gcc -g -O2 -Wall -Wextra -o %%i.exe %%i.c | |
) | |
pause |
This file contains 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
@set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\bin;%PATH% | |
@set MSYSTEM=MINGW64 | |
@rem gdb execvp.exe | |
@rem execvp.exe < txtdata_in.txt > txtdata_out1.txt | |
@rem execvp.exe < txtdata_in.txt > txtdata_out2.txt | |
cat txtdata_in.txt | execvp.exe > txtdata_out1.txt | |
cat txtdata_in.txt | execvp.exe > txtdata_out2.txt | |
@rem cat txtdata_in.txt | execvp.exe | cat | |
@rem cat txtdata_in.txt | execvp.exe | cat | |
@rem inout.exe < txtdata_in.txt > txtdata_out.txt | |
echo ret=%errorlevel% | |
pause |
This file contains 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 <stdio.h> | |
#include <process.h> | |
#include <unistd.h> | |
int main(void) { | |
const char* args[] = {"inout.exe", NULL}; | |
_execvp("inout.exe", args); | |
sleep(30); | |
return 2; | |
} |
This file contains 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 <stdio.h> | |
#include <io.h> | |
#include <unistd.h> | |
int main(void) { | |
char buf[10]; | |
_read(STDIN_FILENO, buf, 1); | |
sleep(10); | |
_write(STDOUT_FILENO, buf, 1); | |
return 4; | |
} |
This file contains 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
abc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment