Im trying to debug program with FILE output, nothing is happening?

Here's my problem: I am trying to get a port knocking program written in C (cd00r.c) to work on my linux debian server. The way its written it only quits if pcap tells it to quit or it's process gets killed. I'm trying to debug output because even though it compiles I test it nothing happens. On top of that, and this may be because I'm a newb, I don't know when the cd00r process quits. I can run it, exit ssh, come back and its not running, or even if I'm testing something by ssh from my laptop, but I'm in front of the server (its running on an old G4 eMac), log in directly check type typing ps and its not running. Like I said I'm a linux newb I assume when I login or ssh in if I run something from whatever directory the process is only local to my connection, like a child process or something, IDK, I havent found anything. If you guys know please let me know.

In the mean time, the basic set up with the file i/o is this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <cstdio>
...
int main
{
   FILE *write_err = fopen("/root/cd00r2/err_log.txt","a+");
   ...
   for(;;)
   {
       //read in packet data
       char * inet="Knock recorded:\n";
       fwrite(inet,sizeof(char),16,write_err);
       inet=sprintf("%s\n\n",inet_ntoa(ip->saddr));
       fwrite(inet,sizeof(char),18,write_err);
       ....
       if(is_open)
       {
           //check for FIN packet to close firewall
       }
       else
       {
           //port knocking check algorithm.
       }
   }
   return 0; //this point is never reached
}


this code spits out an empty file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <cstdio>
...
int main
{
   FILE *write_err = fopen("/root/cd00r2/err_log.txt","a+");
   ...
   for(;;)
   {
       //read in packet data
       char * inet="Knock recorded:\n";
       fwrite(inet,sizeof(char),16,write_err);
       inet=sprintf("%s\n\n",inet_ntoa(ip->saddr));
       fwrite(inet,sizeof(char),18,write_err);
       ....
       if(is_open)
       {
           //check for FIN packet to close firewall
       }
       else
       {
           //port knocking check algorithm.
       }
       fflush(write_err);
   }
   return 0
}


this deleted the file created by the previous version, and didn't do anything else from what I can see.

Is this like java where I have to use fclose() to write to a file? I can't get around trying to figure out where exactly the code runs to exit. I think its being done behind the scenes. I'm still looking through it. What should I do here?
Topic archived. No new replies allowed.