Terrible random bugs...

What signal can make a program suddenly exit [or detach from channel]without
giving any warning?
{I have already catch error for failing in connect to channel}

I have writtern a real time program, which doesn’t use thread, but 5
separate programs running at the same time:
e.g.

…/gameAdmin
…/display_admin
…/painter
…courier
…/player //player1
…/player //player2

Only the program painter will be responsible for output using printf

But strange interrupt happens randomly.Sometimes everything is OK, while
some time one of the program cannot connect to channel. And the painter will
suddenly stop painting without any warning. I have use many printf to debug,
I find that some of the program exit “silently(without any warning)”, and
without running the command line: “name_detach”.

The most strange thing is that, it can stop AT THE MIDDLE of printf command
line,
i.e… output can be just part of the println.

It happens most when I redirect the painter output to a file rather then
print it in standard out.

I dun know how to debug as it comes out RANDOMLY… would anyone suggest
some methods to detect such real time program signal?
Thanks a lot.
()=()=()=()=()=()=()=()=()
^_^!
I ask because I am a novice.
()=()=()=()=()=()=()=()=()

Shirley <novice@hongkong.com> wrote:

What signal can make a program suddenly exit [or detach from channel]without
giving any warning?
{I have already catch error for failing in connect to channel}

I have writtern a real time program, which doesn’t use thread, but 5
separate programs running at the same time:
e.g.

./gameAdmin
./display_admin
./painter
.courier
./player //player1
./player //player2

Only the program painter will be responsible for output using printf

But strange interrupt happens randomly.Sometimes everything is OK, while
some time one of the program cannot connect to channel. And the painter will
suddenly stop painting without any warning. I have use many printf to debug,
I find that some of the program exit “silently(without any warning)”, and
without running the command line: “name_detach”.

The most strange thing is that, it can stop AT THE MIDDLE of printf command
line,
i.e… output can be just part of the println.

It happens most when I redirect the painter output to a file rather then
print it in standard out.

One think to be careful of when redirecting output to a file, is that
the stdio library (i.e. printf) will behave differently when sending
output to a file.

When sending output to a terminal device, stdout will send flush its
local buffers everytime it hits a newline ‘\n’ character. When output
to a file, it will buffer up to 1000 characters, then when it gets that
many, flush that 1000 characters out, and start buffering again.

Also, if your program dies unexpectedly – SIGSEGV or other such crash,
your stdout buffers will not be flushed (as they are if you call exit()),
so you can lose output.

So, when you are re-directed to a file, you are probably NOT dieing
part-way through a printf, you are probably dieing somewhere later, but
losing some of your printf() output.

– try using setvbuf() to force the buffering on your printf()s to
linebuffered all the time [setvbuf(stdio, NULL, _IOLBF, 0 );]
– use stderr (which is unbuffered) for your debug output

Also, check /var/dumps for a program_name.core file – if the program
is dieing an unnatural death, you should get a core file generated.
This can be loaded into the debugger, and may give you enough
information to determine what line you died at.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Are you running XFree86 and QNX 6.1?


Jens


Shirley” <novice@hongkong.com> wrote in message
news:b529j1$7jk$1@inn.qnx.com

What signal can make a program suddenly exit [or detach from
channel]without
giving any warning?
{I have already catch error for failing in connect to channel}

I have writtern a real time program, which doesn’t use thread, but 5
separate programs running at the same time:
e.g.

./gameAdmin
./display_admin
./painter
.courier
./player //player1
./player //player2

Only the program painter will be responsible for output using printf

But strange interrupt happens randomly.Sometimes everything is OK, while
some time one of the program cannot connect to channel. And the painter
will
suddenly stop painting without any warning. I have use many printf to
debug,
I find that some of the program exit “silently(without any warning)”, and
without running the command line: “name_detach”.

The most strange thing is that, it can stop AT THE MIDDLE of printf
command
line,
i.e… output can be just part of the println.

It happens most when I redirect the painter output to a file rather then
print it in standard out.

I dun know how to debug as it comes out RANDOMLY… would anyone suggest
some methods to detect such real time program signal?
Thanks a lot.
()=()=()=()=()=()=()=()=()
^_^!
I ask because I am a novice.
()=()=()=()=()=()=()=()=()