Is it safe to call dlclose (NULL)?

I'm having a failure while passing a pointer nullto dlclose.

Do I need to check for null before calling dlclose?

POSIX doesn't say anything about this: http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlclose.html

Is this undefined behavior or an implementation error dlclose?

+5
source share
3 answers

It's complicated. POSIX declares that

if handlenot related to an open object, dlclose()returns a nonzero value

, , . Linux/Glibc, -, ​​, NULL .

[ , Linux . libdl, POSIX .]

+2

NULL, . , NULL, - ... .

+1

malloc/free (1), . fopen/fclose (2), . , , , .

  • (1) ++ 11
  • (2) . , dtor null, .

, , POSIX, .


Update

I found https://stackoverflow.com/a/6277781/877329 from this answer , and then read man pthread_joinwhich you can call pthread_joinwith an invalid tid that supports.Another malloc/freeproblem I found with the dynamic loader interface is that It does not use a standard error handling system, but has its own function dlerror.

0
source

All Articles