formulahendry / formulahendry/vscode-code-runner
code runner output is different from terminal output[Bug]
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 351
- PR merge metrics
- No merged PRs in 30d
Description
- VS Code Version:
- OS Version:
- Code Runner Version:0.9.15
**Describe the bug**
code runner output is different from terminal output
**To Reproduce**
Steps to reproduce the behavior:
First, in terminal: g++ hm5.8.cpp -o hm5.8 -Wall && "/Users/huangrt01/Desktop/OSTEP/ostep-code/cpu-api/"hm5.8
Second, use the code runner to run the same program.
**Actual behavior**
the terminal outputs 5 lines(expected), but code runner outputs 6 lines.
**Expected behavior**
the output of code runner should have 5 lines.
**Screenshots**


code:
`#include
//#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main(int argc,char*argv[]){
int fd[2];
if(pipe(fd)<0){
cerr<<"pipe failed\n";
exit(1);
}
char *p;
p = (char *)malloc(12 * (sizeof(char *)));
int rc1=fork();
if(rc1<0)
{
// fork failed; exit
cerr << "fork failed\n";
exit(1);
}
else if(rc1==0){
printf("hello, I am child (pid:%d)\n", (int)getpid());
close(fd[0]);
write(fd[1], "hello world\n", 12);
return 0; //否则会继续fork一个进程
}
else if(rc1>0){
printf("hello, I am parent of %d (pid:%d)\n",
rc1, (int)getpid());
}
wait(NULL);
int rc2 = fork();
if (rc2 < 0)
{
// fork failed; exit
cerr << "fork failed\n";
exit(1);
}
else if (rc2 == 0)
{
close(fd[1]);
read(fd[0],p,12);
printf("%s",p);
printf("hello, I am child (pid:%d)\n", (int)getpid());
return 0;
}
else if (rc2 > 0)
{
printf("hello, I am parent of %d (pid:%d)\n",
rc2, (int)getpid());
}
return 0;
}`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.