Click to See Complete Forum and Search --> : Could someone explain to me...


bdg1983
06-11-2001, 08:54 PM
...just why this (http://q3test.2y.net/~moyix/insultd.c) code isn't working? It seems to die just after anything connects to it, but since I've closed down stdin, stdout, and stderr (it's a daemon) I'm not seeing any errors. I'm guessing segfault, but I can't find anything in the code that would do that.

For reference, here (http://tjs.org/~brendan/programming/src/insultd.c) is the last working version of the program. The only difference between it and the current version is that the newer one has a function to randomly pick an insult to display. However, when the new code is moved to another file, like this (http://q3test.2y.net/~moyix/new_code.c), it compiles and runs fine.

I'm hoping this is something obvious and stupid that I've missed.

Thanks,
:confused: moyix :confused:

jemfinch
06-11-2001, 11:41 PM
I'm not really able to check it right now, but perhaps you can use "strace" or "truss" on it to see exactly which call it's dying on.

Jeremy

bdg1983
06-12-2001, 12:43 AM
Ha! Found it!
It was actually a bug in the old code I hadn't noticed; I forgot to put in some checking when I open and write to a log file, and it couldn't write to the log file (permission problem), so it (intelligently enough :rolleyes: ) segfaulted. I had been running the previous version as root, so the problem didn't come up. strace & jemfinch are my new best friends :)

[ 12 June 2001: Message edited by: moyix ]