{"id":286,"date":"2019-10-21T19:32:48","date_gmt":"2019-10-21T17:32:48","guid":{"rendered":"http:\/\/linuxboxen2.dk\/?p=286"},"modified":"2019-10-21T19:32:48","modified_gmt":"2019-10-21T17:32:48","slug":"org_chdir","status":"publish","type":"post","link":"https:\/\/www.linuxboxen.dk\/?p=286","title":{"rendered":"CHDIR"},"content":{"rendered":"<p>CHDIR(2)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Linux Programmer&#8217;s Manual\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CHDIR(2)<\/p>\n<p>NAME<\/p>\n<p>chdir, fchdir &#8211; change working directory<\/p>\n<p>SYNOPSIS<\/p>\n<p>#include &lt;unistd.h&gt;<\/p>\n<p>int chdir(const char *path);<br \/>\nint fchdir(int fd);<\/p>\n<p>Feature Test Macro Requirements for glibc (see feature_test_macros(7)):<\/p>\n<p>fchdir():<br \/>\n_BSD_SOURCE || _XOPEN_SOURCE &gt;= 500 ||<br \/>\n_XOPEN_SOURCE &amp;&amp; _XOPEN_SOURCE_EXTENDED<br \/>\n|| \/* Since glibc 2.12: *\/ _POSIX_C_SOURCE &gt;= 200809L<\/p>\n<p>DESCRIPTION<\/p>\n<p>chdir() changes the current working directory of the calling process<br \/>\nto the directory specified in path.<\/p>\n<p>fchdir() is identical to chdir(); the only difference is that the<br \/>\ndirectory is given as an open file descriptor.<\/p>\n<p>RETURN VALUE<\/p>\n<p>On success, zero is returned.\u00a0 On error, -1 is returned, and errno is<br \/>\nset appropriately.<\/p>\n<p>ERRORS<\/p>\n<p>Depending on the filesystem, other errors can be returned.\u00a0 The more<br \/>\ngeneral errors for chdir() are listed below:<\/p>\n<p>EACCES Search permission is denied for one of the components of path.<br \/>\n(See also path_resolution(7).)<\/p>\n<p>EFAULT path points outside your accessible address space.<\/p>\n<p>EIO\u00a0\u00a0\u00a0 An I\/O error occurred.<\/p>\n<p>ELOOP\u00a0 Too many symbolic links were encountered in resolving path.<\/p>\n<p>ENAMETOOLONG<br \/>\npath is too long.<\/p>\n<p>ENOENT The file does not exist.<\/p>\n<p>ENOMEM Insufficient kernel memory was available.<\/p>\n<p>ENOTDIR<br \/>\nA component of path is not a directory.<\/p>\n<p>The general errors for fchdir() are listed below:<\/p>\n<p>EACCES Search permission was denied on the directory open on fd.<\/p>\n<p>EBADF\u00a0 fd is not a valid file descriptor.<\/p>\n<p>CONFORMING TO<\/p>\n<p>SVr4, 4.4BSD, POSIX.1-2001.<\/p>\n<p>NOTES<\/p>\n<p>The current working directory is the starting point for interpreting<br \/>\nrelative pathnames (those not starting with &#8216;\/&#8217;).<\/p>\n<p>A child process created via fork(2) inherits its parent&#8217;s current<br \/>\nworking directory.\u00a0 The current working directory is left unchanged<br \/>\nby execve(2).<\/p>\n<p>SEE ALSO<\/p>\n<p>chroot(2), getcwd(3), path_resolution(7)<\/p>\n<p>COLOPHON<\/p>\n<p>This page is part of release 3.76 of the Linux man-pages project.\u00a0 A<br \/>\ndescription of the project, information about reporting bugs, and the<br \/>\nlatest version of this page, can be found at<br \/>\nhttp:\/\/www.kernel.org\/doc\/man-pages\/.<\/p>\n<p>Linux\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2010-11-25\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CHDIR(2)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CHDIR(2)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Linux Programmer&#8217;s Manual\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CHDIR(2) NAME chdir, fchdir &#8211; change working directory SYNOPSIS #include &lt;unistd.h&gt; int chdir(const char *path); int fchdir(int fd); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): fchdir(): _BSD_SOURCE || _XOPEN_SOURCE &gt;= 500 || _XOPEN_SOURCE &amp;&amp; _XOPEN_SOURCE_EXTENDED || \/* Since glibc 2.12: *\/ _POSIX_C_SOURCE &gt;= 200809L DESCRIPTION chdir() changes the current working [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[8],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-shell"],"_links":{"self":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}