What happened to my /proc/curproc/file?

Sam Varshavchik mrsam at courier-mta.com
Tue Sep 4 01:51:25 UTC 2012


Am I the only one who's seeing this weirdness with procfs on 9.0-RELEASE-p3.  
Unless I'm overlooking something stupid, a process that rmdir(2)s a  
subdirectory of its current directory ends up with a broken  
/proc/curproc/file symlink:

[mrsam at freebsd ~/stasher/stasher]$ cat t.c
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>

void dump(int n)
{
	char buf[2048];

	printf("Line %d, rc=%s\n", n,
	       (readlink("/proc/curproc/file", buf, 2048) < 0 ? "err":"ok"));
}

int main(int argc, char **argv)
{
	dump(__LINE__);
	mkdir("conftestdir.tst", 0777);
	rmdir("conftestdir.tst");
	dump(__LINE__);
}
[mrsam at freebsd ~/stasher/stasher]$ cc -o t t.c
[mrsam at freebsd ~/stasher/stasher]$ ./t
Line 15, rc=ok
Line 18, rc=err

???????

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20120904/1871365d/attachment.pgp


More information about the freebsd-hackers mailing list