程序可以首先使用aio_read()或aio_write()发出异步I / O操作,然后调用exit()终止自身.
...
aio_write(aiocbp);
exit(0);
我的问题是,exit()调用会一直等到异步I / O完成或程序将直接终止吗?
解决方法:
我相信标准中的相关语言是:
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.
来源: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.
资料来源:http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html
因此,它是未指定的;未完成的操作被取消,或者操作阻塞直到完成.