Tag: 间通信

在连续运行的C和Python应用程序之间传递数据

有没有办法在连续运行的C程序和连续运行的Python程序之间传递数据? C程序首先启动至关重要。 到目前为止,我有(对于C方): void run_cmd(char *cmd[]) { int parentID = getpid(); char str[1*sizeof(double)]; sprintf(str, “%d”, parentID); char* name_with_extension; name_with_extension = malloc(2+strlen(cmd[1])+1*sizeof(int)+1); strcat(name_with_extension, cmd[1]); strcat(name_with_extension, ” “); strcat(name_with_extension, str); pid_t pid; char *argv[] = {“sh”, “-c”, name_with_extension, NULL}; int status; //printf(“Run command: %s\n”, cmd); status = posix_spawn(&pid, “/bin/sh”, NULL, NULL, argv, environ); if (status == 0) […]