【问题标题】:will pthread_exit() closes the opened files too?pthread_exit() 也会关闭打开的文件吗?
【发布时间】:2015-03-16 06:23:04
【问题描述】:

我在线程中打开了一个文件并使用 pthread_exit() 例程终止了该线程。它也会关闭打开的文件吗?

【问题讨论】:

    标签: multithreading pthreads pthread-exit


    【解决方案1】:

    没有。 pthread_exit() 不会关闭任何打开的文件。

    它只释放线程特定的资源。文件描述符是进程范围的,您在线程中打开的任何文件都将保持打开状态,如果您在关闭文件之前调用pthread_exit(),则会发生资源泄漏。

    【讨论】:

    • 不要试图在你的线程中调用 fcloseall() !
    猜你喜欢
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-30
    • 2017-05-26
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    相关资源
    最近更新 更多