Zohar Argov Zohar Argov - 5 months ago 10
Linux Question

open file linux eclipse c error after getchld

im just trying to open a file.
i have done it for 100 times, and then I sent SIGCHLD signal to other processes and i think right after that i couldn't open that file anymore.

#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

#define FLAGS IPC_CREAT | 0644
int main() {
int res =open("results.txt",FLAGS);
if(res== -1) { printf("error!!")} //prints it every time
return 0;}


..it suddenly just happened.. help ???

Answer

You're doing something strange with the flags. I think your intention is as per below code:

#define FLAGS O_CREAT
#define MODE 0644
int main()  
{
    int res =open("results.txt",FLAGS,MODE);
    if(res== -1) { printf("error!!")}   //prints it every time
    return 0;
}
Comments