{"id":246,"date":"2015-07-21T16:13:06","date_gmt":"2015-07-21T20:13:06","guid":{"rendered":"http:\/\/72.167.111.237\/wpecsdump\/?page_id=246"},"modified":"2015-07-21T16:13:06","modified_gmt":"2015-07-21T20:13:06","slug":"notes-on-open-watcom-_pipe","status":"publish","type":"page","link":"https:\/\/www.ecsdump.net\/?page_id=246","title":{"rendered":"Notes on Open Watcom _pipe"},"content":{"rendered":"<h3>The synopsis is at the bottom of page and I am only concern with OS2 __386__.<\/h3>\n<p>int _pipe( int *phandles, unsigned psize, int textmode );<\/p>\n<p>If psize == 0 then default size of 4096 will be used.\u00a0<\/p>\n<p>HFILE hRead<br \/>HFILE hWrite;<\/p>\n<p>APIRET rc;<\/p>\n<p>rc = DosCreatePipe( &amp;hRead, &amp;hWrite, psize );<\/p>\n<p>Handle is inheritable by default<\/p>\n<p>Initialize the POSIX-level handles\u00a0<\/p>\n<p>&nbsp;<\/p>\n<div class=\"indent\">hReadPosix = _hdopen( (int)hRead, textmode|_O_RDONLY );<br \/>hWritePosix = _hdopen( (int)hWrite, textmode|_O_WRONLY );<\/div>\n<p>The _hdopen function takes a previously opened operating system file handle specified by os_handle and opened with access and sharing specified by mode, and creates a POSIX-style file handle.\u00a0<\/p>\n<p>Store the new POSIX handles in return buffer<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"indent\">phandles[0] = hReadPosix;<br \/>phandles[1] = hWritePosix;<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p><strong>Synopsis:<\/strong><\/p>\n<p>#include\u00a0<br \/>int _pipe( int *phandles, unsigned psize, int textmode );\u00a0<\/p>\n<p><strong>Description:<\/strong>\u00a0<br \/>The _pipe function creates a pipe (an unnamed FIFO) and places a file descriptor for the read end of the pipe in phandles[0] and a file descriptor for the write end of the pipe in phandles[1]. Their integer values are the two lowest available at the time of the _pipe function call. The O_NONBLOCK flag is cleared for both file descriptors. (The fcntl call can be used to set the O_NONBLOCK flag.)\u00a0<\/p>\n<p>Data can be written to file descriptor phandles[1] and read from file descriptor phandles[0]. A read on file descriptor phandles[0] returns the data written to phandles[1] on a first-in-first-out (FIFO) basis.\u00a0<\/p>\n<p>This function is typically used to connect together standard utilities to act as filters, passing the write end of the pipe to the data producing process as its STDOUT_FILENO and the read end of the pipe to the data consuming process as its STDIN_FILENO. (either via the traditional fork\/dup2\/exec or the more efficient spawn calls).\u00a0<\/p>\n<p>If successful, _pipe marks for update the st_ftime, st_ctime, st_atime and st_mtime fields of the pipe for updating.\u00a0<\/p>\n<p><strong>Returns:<\/strong>\u00a0<br \/>The _pipe function returns zero on success. Otherwise, (-1) is returned and errno is set to indicate the error.\u00a0<\/p>\n<p>Errors:\u00a0<br \/>When an error has occurred, errno contains a value indicating the type of error that has been detected. If any of the following conditions occur, the _pipe function shall return (-1) and set errno to the corresponding value:\u00a0<\/p>\n<p>Constant Meaning\u00a0<br \/>EMFILE The calling process does not have at least 2 unused file descriptors available.\u00a0<br \/>ENFILE The number of simultaneously open files in the system would exceed the configured limit.\u00a0<br \/>ENOSPC There is insufficient space available to allocate the pipe buffer.\u00a0<br \/>EROFS The pipe pathname space is a read-only filesystem.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The synopsis is at the bottom of page and I am only concern with OS2 __386__. int _pipe( int *phandles, unsigned psize, int textmode ); If psize == 0 then default size of 4096 will be used.\u00a0 HFILE hReadHFILE hWrite; APIRET rc; rc = DosCreatePipe( &amp;hRead, &amp;hWrite, psize ); Handle is inheritable by default Initialize&hellip;<\/p>\n<p><a class=\"more-link\" href=\"https:\/\/www.ecsdump.net\/?page_id=246\" title=\"Continue reading &lsquo;Notes on Open Watcom _pipe&rsquo;\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":243,"menu_order":4,"comment_status":"open","ping_status":"open","template":"page-templates\/info_static.php","meta":{"footnotes":""},"categories":[],"tags":[],"wf_page_folders":[79],"class_list":["post-246","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages\/246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=246"}],"version-history":[{"count":0,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages\/246\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=\/wp\/v2\/pages\/243"}],"wp:attachment":[{"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=246"},{"taxonomy":"wf_page_folders","embeddable":true,"href":"https:\/\/www.ecsdump.net\/index.php?rest_route=%2Fwp%2Fv2%2Fwf_page_folders&post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}