Re: deleting a copy of a dylib fails after dlcose
Re: deleting a copy of a dylib fails after dlcose
- Subject: Re: deleting a copy of a dylib fails after dlcose
- From: "Peter O'Gorman" <email@hidden>
- Date: Thu, 7 Dec 2006 07:57:08 -0500
On Dec 5, 2006, at 10:46 PM, Alfred Van Hoek wrote:
We usually copy our custom dylib to a temporary folder, call
dlopen, dlsym and at last dlclose. No errors. Then we want to
delete the dylib but an error 104 is produced, file in use. Why is
this happening, and what is the remedy?
How are you trying to delete the file?
You should be able to unlink(2) immediately after the dlopen(3),
there is no need to wait until after the dlclose.
Peter
---
19% ls
bundle.c main.c
19% cat bundle.c
int bundle_value = 42;
19% cat main.c
#include <stdio.h>
#include <dlfcn.h>
#include <unistd.h>
#include <sys/errno.h>
#include <stdlib.h>
int main (int argc, const char * argv[])
{
/* No error checking - eek */
void * handle = NULL;
int * value = 0;
handle = dlopen(argv[1],RTLD_GLOBAL);
if (unlink(argv[1]) == -1) exit (errno);
value=dlsym(handle,"bundle_value");
printf("The Value is: %d\n",*value);
dlclose(handle);
return 0;
}
19% cc -o main main.c
19% cc -dynamiclib -o lib.dylib bundle.c
19% ./main ./lib.dylib
The Value is: 42
19% echo $?
0
19% ls
bundle.c main main.c
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden