0

我有一个父进程'A'和一个子进程'B'。子进程就像一个控制台进程,它是这样实现的..

#include<iostream>
#include<cstdio>

    int main()
    {
        char inputCommand[50];
        while(1)
        {
            cout<<"CONSOLE>";
            cout.flush();
            strcpy(inputCommand,"");    
            __fpurge(stdin);
            scanf(" %s",inputCommand);
            return 0;
            // here I have an array of commands
            // next i am comparing the input command with the array and getting a number
            // next i am having a swith statement which do some action according to the 
            // input command. 
            // default case is :: no command found!! 

        }
    }

在正常情况下,此应用程序工作正常。但是,当我使用 tcsetpgrp() 将进程“B”设置为活动进程或使用 & 在后台运行进程“A”以将信号重定向到进程“B”而不是“A”时,进程“B”不是阻塞在 scanf() 和“找不到命令!!” 是否连续打印在屏幕上?请帮我解决这个问题。

谢谢。

4

0 回答 0