首页 > 解决方案 > 将system()函数的显示传递给一个fifo

问题描述

我想在 fifo 中传递 system() 函数执行的显示,以便能够在另一个终端上显示它,我尝试了 a 但它给了我一个分段错误

void executeFile(char* sourcefname,struct Info_FIFO_Transaction donnees){


    char *nomFichier, *sp;
    char command[100];
    int client_fifo_fd;
    char client_fifo[400];
    sprintf(client_fifo, CLIENT_FIFO_NAME, donnees.pid_client);
    client_fifo_fd = open(client_fifo, O_WRONLY);
    
    nomFichier = strtok_r(sourcefname, ".", &sp); 

    sprintf(command,"gcc -o fichCVSEXE%s %s.c\n",nomFichier,nomFichier);
        // execution of file
    strcat(donnees.transaction ,system(command));
    if(client_fifo_fd!=-1){
    write(client_fifo_fd, &donnees, sizeof(donnees));
        close(client_fifo_fd);}
}

标签: clinuxdirectoryfifomkfifo

解决方案


推荐阅读