C – Exits when performing asynchronous I/O operations

Exits when performing asynchronous I/O operations… here is a solution to the problem.

Exits when performing asynchronous I/O operations

A program might first issue asynchronous I/O operations using aio_read() or aio_write() and then call exit() to terminate itself.


My question is, will the exit() call wait until the asynchronous I/O completes or will the program simply terminate?


I believe the relevant language in the standard is:

Consequences of Process Termination

All of the file descriptors, directory streams, conversion descriptors, and message catalog descriptors open in the calling process shall be closed.

Source: http://pubs.opengroup.org/onlinepubs/9699919799/functions/_Exit.html


When there is an outstanding cancelable asynchronous I/O operation against fildes when close() is called, that I/O operation may be canceled. An I/O operation that is not canceled completes as if the close() operation had not yet occurred. All operations that are not canceled shall complete as if the close() blocked until the operations completed. The close() operation itself need not block awaiting such I/O completion. Whether any I/O operation is canceled, and which I/O operation may be canceled upon close(), is implementation-defined.

Source: http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html

Therefore, it is unspecified; Either cancel the outstanding operation, or the operation blocks until it completes.

Related Problems and Solutions