<!DOCTYPE html>
<html class="client-js"><head>
  <meta charset="UTF-8">
  <title>unistd.h</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script>
    function importScript() { return 1 } // this is to avoid the error from site.js
  </script>
  <script>let articleId = 'Unistd.h'</script>
  <link rel="canonical" href="https://en.wikipedia.org/wiki/Unistd.h">
  <link href="../-/mw/skins.minerva.base.reset|skins.minerva.content.styles|ext.cite.style|site.styles|mobile.app.pagestyles.android|mediawiki.page.gallery.styles|mediawiki.skinning.content.parsoid.css" rel="stylesheet" type="text/css">
  <link href="../-/style.css" rel="stylesheet" type="text/css"><link href="../-/content.parsoid.css" rel="stylesheet" type="text/css"><link href="../-/inserted_style.css" rel="stylesheet" type="text/css">
  <script src="../-/script.js"></script><script src="../-/masonry.min.js"></script><script src="../-/article_list_home.js"></script><script src="../-/images_loaded.min.js"></script><script src="../-/node_module/details-element-polyfill/dist/details-element-polyfill.js"></script>
</head>

<body class="mediawiki mw-hide-empty-elt ns-0 ns-subject stable skin-minerva action-view animations">
  <div id="mw-mf-viewport" class="feature-header-v2">
    <div id="mw-mf-page-center">
      <div id="content" class="mw-body">
        <a id="top"></a>
        <div id="bodyContent" class="content mw-parser-output">
          
          <div id="mw-content-text" style="direction: ltr;"><h1 class="section-heading" tabindex="0" aria-haspopup="true" data-section-id="0">
  <span class="mw-headline" id="title_0">unistd.h</span>
</h1>
<div id="mf-section-0" class="mf-section-0" aria-pressed="true" aria-expanded="true">
  <p>In the <a href="C_programming_language" title="C programming language" class="mw-redirect">C</a> and <a href="C%2B%2B" title="C++">C++</a> programming languages, <code><b>unistd.h</b></code> is the name of the <a href="Header_file" title="Header file" class="mw-redirect">header file</a> that provides access to the <a href="POSIX" title="POSIX">POSIX</a> <a href="Operating_system" title="Operating system">operating system</a> <a href="Application_programming_interface" title="Application programming interface" class="mw-redirect">API</a>. It is defined by the POSIX.1 standard, the base of the <a href="Single_Unix_Specification" title="Single Unix Specification" class="mw-redirect">Single Unix Specification</a>, and should therefore be available in any POSIX-compliant operating system and <a href="Compiler" title="Compiler">compiler</a>. For instance, this includes <a href="Unix" title="Unix">Unix</a> and <a href="Unix-like" title="Unix-like">Unix-like</a> operating systems, such as <a href="GNU_variants" title="GNU variants">GNU variants</a>, distributions of <a href="Linux" title="Linux">Linux</a> and <a href="BSD" title="BSD" class="mw-redirect">BSD</a>, and <a href="MacOS" title="MacOS">macOS</a>, and compilers such as <a href="GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a> and <a href="LLVM" title="LLVM">LLVM</a>.</p>


<p><span>
</span><meta property="mw:PageProp/displaytitle" content="unistd.h"></p>

<style data-mw-deduplicate="TemplateStyles:r1002931532">.mw-parser-output .sidebar{width:22em;float:right;clear:right;margin:0.5em 0 1em 1em;background:#f8f9fa;border:1px solid #aaa;padding:0.2em;border-spacing:0.4em 0;text-align:center;line-height:1.4em;font-size:88%}.mw-parser-output .sidebar a{white-space:nowrap}.mw-parser-output .sidebar-wraplinks a{white-space:normal}.mw-parser-output .sidebar-subgroup{width:100%;margin:0;border-spacing:0}.mw-parser-output .sidebar-left{float:left;clear:left;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-none{float:none;clear:both;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-outer-title{padding-bottom:0.2em;font-size:125%;line-height:1.2em;font-weight:bold}.mw-parser-output .sidebar-top-image{padding:0.4em 0}.mw-parser-output .sidebar-top-caption,.mw-parser-output .sidebar-pretitle-with-top-image,.mw-parser-output .sidebar-caption{padding-top:0.2em;line-height:1.2em}.mw-parser-output .sidebar-pretitle{padding-top:0.4em;line-height:1.2em}.mw-parser-output .sidebar-title,.mw-parser-output .sidebar-title-with-pretitle{padding:0.2em 0.4em;font-size:145%;line-height:1.2em}.mw-parser-output .sidebar-title-with-pretitle{padding-top:0}.mw-parser-output .sidebar-image{padding:0.2em 0 0.4em}.mw-parser-output .sidebar-heading{padding:0.1em}.mw-parser-output .sidebar-content{padding:0 0.1em 0.4em}.mw-parser-output .sidebar-content-with-subgroup{padding:0.1em 0 0.2em}.mw-parser-output .sidebar-above,.mw-parser-output .sidebar-below{padding:0.3em 0.4em;font-weight:bold}.mw-parser-output .sidebar-collapse .sidebar-above,.mw-parser-output .sidebar-collapse .sidebar-below{border-top:1px solid #aaa;border-bottom:1px solid #aaa}.mw-parser-output .sidebar-navbar{text-align:right;font-size:115%}.mw-parser-output .sidebar-collapse .sidebar-navbar{padding-top:0.6em}.mw-parser-output .sidebar-collapse .mw-collapsible-toggle{margin-top:0.2em}.mw-parser-output .sidebar-list-title{text-align:left;font-weight:bold;line-height:1.6em;font-size:105%}@media(max-width:720px){body.mediawiki .mw-parser-output .sidebar{width:100%!important;clear:both;float:none;margin-left:0!important;margin-right:0!important}}</style><table class="sidebar vertical-navbox nomobile"><tbody><tr><th class="sidebar-title"><a href="C_POSIX_library" title="C POSIX library">C POSIX library</a></th></tr><tr><td class="sidebar-content" style="text-align:left">
<ul><li><code>&lt;<a href="Assert.h" title="Assert.h">assert.h</a>&gt;</code></li>
<li><code>&lt;<a href="Complex.h" title="Complex.h" class="mw-redirect">complex.h</a>&gt;</code></li>
<li><code>&lt;<a href="Ctype.h" title="Ctype.h" class="mw-redirect">ctype.h</a>&gt;</code></li>
<li><code>&lt;<a href="Dirent.h" title="Dirent.h" class="mw-redirect">dirent.h</a>&gt;</code></li>
<li><code>&lt;<a href="Dlfcn.h" title="Dlfcn.h" class="mw-redirect">dlfcn.h</a>&gt;</code></li>
<li><code>&lt;<a href="Errno.h" title="Errno.h">errno.h</a>&gt;</code></li>
<li><code>&lt;<a href="Fcntl.h" title="Fcntl.h" class="mw-redirect">fcntl.h</a>&gt;</code></li>
<li><code>&lt;<a href="Fenv.h" title="Fenv.h" class="mw-redirect">fenv.h</a>&gt;</code></li>
<li><code>&lt;<a href="Float.h" title="Float.h" class="mw-redirect">float.h</a>&gt;</code></li>
<li><code>&lt;<a href="Inttypes.h" title="Inttypes.h" class="mw-redirect">inttypes.h</a>&gt;</code></li>
<li><code>&lt;<a href="Iso646.h" title="Iso646.h" class="mw-redirect">iso646.h</a>&gt;</code></li>
<li><code>&lt;<a href="Limits.h" title="Limits.h" class="mw-redirect">limits.h</a>&gt;</code></li>
<li><code>&lt;<a href="Locale.h" title="Locale.h" class="mw-redirect">locale.h</a>&gt;</code></li>
<li><code>&lt;<a href="Math.h" title="Math.h" class="mw-redirect">math.h</a>&gt;</code></li>
<li><code>&lt;<a href="Pthread.h" title="Pthread.h" class="mw-redirect">pthread.h</a>&gt;</code></li>
<li><code>&lt;<a href="Setjmp.h" title="Setjmp.h">setjmp.h</a>&gt;</code></li>
<li><code>&lt;<a href="Signal.h" title="Signal.h" class="mw-redirect">signal.h</a>&gt;</code></li>
<li><code>&lt;<a href="Stdarg.h" title="Stdarg.h">stdarg.h</a>&gt;</code></li>
<li><code>&lt;<a href="Stdbool.h" title="Stdbool.h" class="mw-redirect">stdbool.h</a>&gt;</code></li>
<li><code>&lt;<a href="Stddef.h" title="Stddef.h" class="mw-redirect">stddef.h</a>&gt;</code></li>
<li><code>&lt;<a href="Stdint.h" title="Stdint.h" class="mw-redirect">stdint.h</a>&gt;</code></li>
<li><code>&lt;<a href="Stdio.h" title="Stdio.h" class="mw-redirect">stdio.h</a>&gt;</code></li>
<li><code>&lt;<a href="Stdlib.h" title="Stdlib.h" class="mw-redirect">stdlib.h</a>&gt;</code></li>
<li><code>&lt;<a href="String.h" title="String.h" class="mw-redirect">string.h</a>&gt;</code></li>
<li><code>&lt;<a href="Sys/stat.h" title="Sys/stat.h" class="mw-redirect">sys/stat.h</a>&gt;</code></li>
<li><code>&lt;<a href="Tgmath.h" title="Tgmath.h" class="mw-redirect">tgmath.h</a>&gt;</code></li>
<li><code>&lt;<a href="Time.h" title="Time.h" class="mw-redirect">time.h</a>&gt;</code></li>
<li><code>&lt;<a href="Unistd.h" title="Unistd.h">unistd.h</a>&gt;</code></li>
<li><code>&lt;<a href="Utime.h" title="Utime.h" class="mw-redirect">utime.h</a>&gt;</code></li>
<li><code>&lt;<a href="Wchar.h" title="Wchar.h" class="mw-redirect">wchar.h</a>&gt;</code></li>
<li><code>&lt;<a href="Wctype.h" title="Wctype.h" class="mw-redirect">wctype.h</a>&gt;</code></li></ul></td>
</tr><tr><td class="sidebar-navbar"><style data-mw-deduplicate="TemplateStyles:r992953826">.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}.mw-parser-output .infobox .navbar{font-size:100%}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}</style></td></tr></tbody></table>
<p>On Unix-like systems, the interface defined by <code>unistd.h</code> is typically made up largely of <a href="System_call#The_library_as_an_intermediary" title="System call">system call wrapper functions</a> such as <code><a href="Fork_(operating_system)" title="Fork (operating system)" class="mw-redirect">fork</a></code>, <code><a href="Pipeline_(Unix)" title="Pipeline (Unix)">pipe</a></code> and <a href="Input/output" title="Input/output">I/O</a> primitives (<code>read</code>, <code>write</code>, <code>close</code>, etc.).</p>

<p>Unix compatibility layers such as <a href="Cygwin" title="Cygwin">Cygwin</a> and <a href="MinGW" title="MinGW">MinGW</a> also provide their own versions of unistd.h. In fact, those systems provide it along with the translation libraries that implement its functions in terms of Win32 functions. E.g. In Cygwin, a header file can be found in <code>/usr/include</code> that sub-includes a file of the same name in <code>/usr/include/sys</code>. Not everything is defined in there but some definitions are done by references to the GNU C standard library headers (like <a href="Stddef.h" title="Stddef.h" class="mw-redirect">stddef.h</a>) which provide the type <a href="Size_t" title="Size t" class="mw-redirect">size_t</a> and many more. Thus, unistd.h is only a generically defined adaptive layer that might be based upon already existing system and compiler specific definitions. This has the general advantage of not having a possibly concurrent set of header file defined, but one that is built upon the same root which, for this reason, will raise much fewer concerns in combined usage cases.</p>


</div><details data-level="2" open="">
    <summary class="section-heading"><h2 id="External_links">External links</h2></summary>
    
<ul><li><span class="neverexpand"><code><a href="https://www.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html" class="external text external">unistd.h</a></code></span><span>:</span><span>&nbsp;</span><span>standard symbolic constants and types</span><span>&nbsp;</span><span>–</span><span>&nbsp;</span><span>Base Definitions Reference, </span><a href="Single_Unix_Specification" title="Single Unix Specification" class="mw-redirect">The Single UNIX Specification</a><span>, Issue 7 from </span><a href="The_Open_Group" title="The Open Group">The Open Group</a></li></ul>




    
</details><!--htdig_noindex--><div><div style="clear:both; background-image:linear-gradient(180deg, #E8E8E8, white); border-top: dashed 2px #AAAAAA; padding: 0.5em 0.5em 0.5em 0.5em; margin-top: 1em; direction: ltr;">
    This article is issued from <a class="external text" title="Last edited on 2020-11-12" href="https://en.wikipedia.org/wiki/?title=Unistd.h&amp;oldid=988298711">Wikipedia</a>. The text is licensed under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons - Attribution - Sharealike</a>. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
        </div>
      </div>
    </div>
  </div>
  <script src="../-/mw/jsConfigVars.js"></script>
  <script src="../-/mw/startup.js"></script>
<script src="../-/mw/jquery.js"></script>
<script src="../-/mw/mediawiki.js"></script>
<script src="../-/mw/site.js"></script>



</body></html>