site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=subject :mime-version:content-type:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; s=sasl; bh= tsBJzttjF9bYpgOlTJNnJ72GQiM=; b=AiI2klyOTXCIB9aMNoQc9+E+tlUlDZ6E lD7PQ0wo1yQwhDTauLUBuTpBqXFxNoTHc1C02nHHDIsvkT4qiHhduLbvQVXc7RG1 RRadJ4QIsKf4oNu7wbOiIS3vDemOTqIyHd+B3E5EQV5vTcQIzvvv5ghDRbkxVy+C +YGKVcj6Hoc= Domainkey-signature: a=rsa-sha1; c=nofws; d=pobox.com; h=subject :mime-version:content-type:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; q=dns; s= sasl; b=U23NgxClhqCmMk996UlXhtb50MzzA1GoAWiikQLrJAykl2p5Lc0OiYIS QiDcpmfmlZJbKypKovDey5/RxJ3UKRg1GH8ICsJwRi5AHyHcZP6heanUd8mTGPSh PpjyujWX42ughjLmggq/34FQY0oNPy8d1JTIE391MZbQ9cxRFcM= On May 3, 2011, at 9:13 AM, Anatol Pomozov wrote:
Hi,
I am porting a Linux program to macosx (target is 10.6 version) and the program uses openat/unlinkat/... functions. Although these functions are not in POSIX, they are widely used on *nixes and the part proposal the next POSIX.
My question what is the best equivalent for the opentat() functions that can be used in multithreaded application. Currently I use something like this:
int openat(int dirfd, const char *pathname, int flags, ...) { int fd;
if(fchdir(dirfd) < 0) { perror("fchdir"); return -1; } fd = open(pathname, flags, mode); // chdir to the original CWD return fd; }
But this is not a perfect solution - current working directory is shared among all threads, it means that openat() may affect other threads. Is there an equivalent of this implementation without changing the current directory?
Use a per-thread CWD? Darwin supports them but I can't figure where/whether it is documented. A previous reference to this capability, from an apple.com address: <http://lists.apple.com/archives/unix-porting/2008/Mar/msg00028.html> However, in my opinion, the openat()/... functions are good deal more convenient than per-thread CWDs. I'm glad to hear that they are considered for inclusion in an upcoming revision of POSIX. Eric _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com