Tag: execl

通过C中的argv使用管道发送和接收字符数组

所以,我正在尝试创建一个管道,通过argv []连接的管道来回发送char数组。 现在,我一直坚持在接口中接收数组(从父节点发送到子节点的c_param的参数)。在db.c中接收字符3和5。 我知道3和5是我的管道所在的argv []的索引,但我不知道如何接受它并在db.c中打印出我的消息。 interface.c创建管道,分叉到父进程和子进程。 char数组param被转移到子进程到char数组c_param。 使用snprintf,我将我的管道变成了一个char,使用execl和我的char数组c_param发送。 interface.c: int main (int argc, char *argv[]) { int to_Child[2]; int to_Parent[2]; int id, toChildPipe, toParentPipe, err; char param[100] = “This is the parameter!”; char sendPipe[100]; char recPipe[100]; /*CREATING PIPE*/ toChildPipe = pipe(to_Child); toParentPipe = pipe(to_Parent); if(toChildPipe == -1 || toParentPipe == -1) { printf (“Error on […]