mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add research for usage for subprocess
This commit is contained in:
parent
cccc483ab3
commit
b7d8be46a1
2 changed files with 86 additions and 0 deletions
32
trunk/research/python-subprocess/python.subprocess.cpp
Normal file
32
trunk/research/python-subprocess/python.subprocess.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
# always to print to stdout and stderr.
|
||||
g++ python.subprocess.cpp -o python.subprocess
|
||||
*/
|
||||
int main(int argc, char** argv) {
|
||||
if (argc <= 2) {
|
||||
printf("Usage: <%s> <interval_ms> <max_loop>\n"
|
||||
" %s 50 100000\n", argv[0], argv[0]);
|
||||
exit(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int interval_ms = ::atoi(argv[1]);
|
||||
int max_loop = ::atoi(argv[2]);
|
||||
printf("always to print to stdout and stderr.\n");
|
||||
printf("interval: %d ms\n", interval_ms);
|
||||
printf("max_loop: %d\n", max_loop);
|
||||
|
||||
for (int i = 0; i < max_loop; i++) {
|
||||
fprintf(stdout, "always to print to stdout and stderr. interval=%dms, max=%d, current=%d\n", interval_ms, max_loop, i);
|
||||
fprintf(stderr, "always to print to stdout and stderr. interval=%dms, max=%d, current=%d\n", interval_ms, max_loop, i);
|
||||
if (interval_ms > 0) {
|
||||
usleep(interval_ms * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue