Re: Fwd: Re: exit(1) pb
On Wednesday 27 June 2001 09:50, Rogier Wolff wrote:
> My guess:
> The "exit" contains an implicit "close all file descriptors".
> The "close a serial line filedescriptor" may want to flush all
> characters that were sent. If for example the device at the other end
> signals "please don't send anything" through the handshaking, then
> "wait until everything is sent" can take a noticable amount of time...
You are right!!!
As opening lots of file descriptors and never ever closing them is a bug
anyway I decided to go through my code and make sure that every file
descriptor is closed the moment it is no longer needed.
Now when I detect an error I do:
As all three file handles refer to the serial device. The close(2)
statement closes the last open file handle for the serial device and is
So then I added the following code before closing the tty:
Now my program works fine! Rogier you are a programming god! Thanks for
> How the alignment of your code happens to affect all this is beyond
> > The problem is that my program will get stuck apparently in kernel
> > mode after calling exit(). Strace etc will all show that it has
> > called exit() and never returned. Returning a value from the main()
> > function has the same result as calling exit() in that the program
> > halts but does not exit.
http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/ Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/ My home page