Fork() problem
Hello,
I'm writing an daemon C-program for linux but I got a strange problem with fork(). When I call an function located in another c-file the program just dissappears... This is the way I've done it:
I define prototypes of all functions in a common header file (header.h) which I include in all c-files. If i comment the action(&value) part, it will run on and on in the while(1) loop until I kill it with a SIGKILL. Am I using fork wrong here or is fork messing with me? As far as I understand with my scills in C this should work just fine since I'm including this header file with prototypes an link the compiled files as supposed to. The compiler is not complaining about anything... I cannot find anything about this kind of problems anywhere :study: |
What exactly does action() do? Can you post the code?
The reason I ask is because weird things seem to happen with I/O in fork()'d processes. Like this: Code:
itsme@itsme:~/C$ cat fork.c Code:
itsme@itsme:~/C$ ./fork |
Instead of this:
Code:
if (fork() >0) { Code:
if (daemon(0,0) < 0) { Code:
if ((fork()) != 0) |
Thanx for the reply, I was going to post the code when I noticed an declaration I hade
Code:
FILE *fp; Code:
fclose(fp); My bad :) I would have expected some complains from the gcc though.. |
All times are GMT -5. The time now is 01:09 AM. |