Please have a look on this code:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
FILE *process_fp = popen("make -f -", "w");
if (process_fp == NULL) {
printf("[ERR] make not found!\n");
} else {
char txt[1024] = "all:\n\t@echo Hello World!\n";
fwrite(txt, sizeof(char), strlen(txt), process_fp);
pclose(process_fp);
}
}
This program will print "Hello World!". It works on the Linux platform, but failed on Solaris, where it complains: make: *** fopen (temporary file): No such file or directory. Stop.
.
How can I solve this problem?