157 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Groff
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Groff
		
	
	
	
	
	
| .\" Copyright (c) 1980, 1991, 1993
 | |
| .\"	The Regents of the University of California.  All rights reserved.
 | |
| .\"
 | |
| .\" Redistribution and use in source and binary forms, with or without
 | |
| .\" modification, are permitted provided that the following conditions
 | |
| .\" are met:
 | |
| .\" 1. Redistributions of source code must retain the above copyright
 | |
| .\"    notice, this list of conditions and the following disclaimer.
 | |
| .\" 2. Redistributions in binary form must reproduce the above copyright
 | |
| .\"    notice, this list of conditions and the following disclaimer in the
 | |
| .\"    documentation and/or other materials provided with the distribution.
 | |
| .\" 3. All advertising materials mentioning features or use of this software
 | |
| .\"    must display the following acknowledgement:
 | |
| .\"	This product includes software developed by the University of
 | |
| .\"	California, Berkeley and its contributors.
 | |
| .\" 4. Neither the name of the University nor the names of its contributors
 | |
| .\"    may be used to endorse or promote products derived from this software
 | |
| .\"    without specific prior written permission.
 | |
| .\"
 | |
| .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 | |
| .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | |
| .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 | |
| .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 | |
| .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | |
| .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 | |
| .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | |
| .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | |
| .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 | |
| .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | |
| .\" SUCH DAMAGE.
 | |
| .\"
 | |
| .\"     @(#)dup.2	8.1 (Berkeley) 6/4/93
 | |
| .\" %FreeBSD: src/lib/libc/sys/dup.2,v 1.21 2004/07/02 23:52:13 ru Exp %
 | |
| .\"
 | |
| .\" $FreeBSD$
 | |
| .Dd June 4, 1993
 | |
| .Dt DUP 2
 | |
| .Os
 | |
| .Sh ̾¾Î
 | |
| .Nm dup ,
 | |
| .Nm dup2
 | |
| .Nd ´û¸¤Î¥Õ¥¡¥¤¥ëµ½Ò»Ò¤òÊ£À½¤¹¤ë
 | |
| .Sh ¥é¥¤¥Ö¥é¥ê
 | |
| .Lb libc
 | |
| .Sh ½ñ¼°
 | |
| .In unistd.h
 | |
| .Ft int
 | |
| .Fn dup "int oldd"
 | |
| .Ft int
 | |
| .Fn dup2 "int oldd" "int newd"
 | |
| .Sh ²òÀâ
 | |
| .Fn dup
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢´û¸¤Î¥ª¥Ö¥¸¥§¥¯¥Èµ½Ò»Ò¤òÊ£À½¤·¡¢
 | |
| ¤½¤ÎÃͤò¸Æ¤Ó½Ð¤·¥×¥í¥»¥¹¤ËÊÖ¤·¤Þ¤¹
 | |
| .Fa ( newd
 | |
| =
 | |
| .Fn dup oldd )
 | |
| ¡£
 | |
| °ú¿ô
 | |
| .Fa oldd
 | |
| ¤Ï¥×¥í¥»¥¹¤Îµ½Ò»Ò¥Æ¡¼¥Ö¥ëÆâ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç¡¢Éé¤Ç¤Ê¤¤¾®¤µ¤ÊÀ°¿ô¤Ç¤¹¡£
 | |
| ¤½¤ÎÃͤϥơ¼¥Ö¥ë¤Î¥µ¥¤¥º¤è¤ê¾®¤µ¤¯¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
 | |
| ¥Æ¡¼¥Ö¥ë¤Î¥µ¥¤¥º¤Ï
 | |
| .Xr getdtablesize 2
 | |
| ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤Þ¤¹¡£
 | |
| .Fn dup
 | |
| ¸Æ¤Ó½Ð¤·¤Ï¡¢¤½¤Î¤È¤¤Ë¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤Æ¤¤¤Ê¤¤ÈÖ¹æ¤Î¤¦¤Á¡¢
 | |
| ºÇ¤â¾®¤µ¤¤ÈÖ¹æ¤ÎÉÕ¤¤¤¿µ½Ò»Ò¤òÊÖ¤·¤Þ¤¹¡£
 | |
| .Pp
 | |
| µ½Ò»Ò¤¬»²¾È¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ï
 | |
| .Fa oldd
 | |
| ¤È
 | |
| .Fa newd
 | |
| ¤ò¤Þ¤Ã¤¿¤¯¶èÊ̤·¤Þ¤»¤ó¡£
 | |
| ¤·¤¿¤¬¤Ã¤Æ
 | |
| .Fa newd
 | |
| ¤È
 | |
| .Fa oldd
 | |
| ¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ø¤ÎÊ£À½¤µ¤ì¤¿»²¾È¤À¤Ã¤¿¾ì¹ç¡¢¤¹¤Ù¤Æ¤Î
 | |
| .Xr read 2 ,
 | |
| .Xr write 2
 | |
| ¤ª¤è¤Ó
 | |
| .Xr lseek 2
 | |
| ¸Æ¤Ó½Ð¤·¤Ï¡¢Ã±°ì¤Î¥Ý¥¤¥ó¥¿¤ò¥Õ¥¡¥¤¥ëÆâ¤Ç°Üư¤·¤Þ¤¹¡£
 | |
| Äɲå⡼¥É¡¢¥Î¥ó¥Ö¥í¥Ã¥¥ó¥°Æþ½ÐÎÏ
 | |
| ¤ª¤è¤ÓÈ󯱴üÆþ½ÐÎÏ¥ª¥×¥·¥ç¥ó¤Ï³Æ»²¾È¤Î´Ö¤Ç¶¦Í¤µ¤ì¤Þ¤¹¡£
 | |
| °ì¤Ä¤Î¥Õ¥¡¥¤¥ë¤Ø¤ÎÊÌ¡¹¤Î¥Ý¥¤¥ó¥¿¤¬É¬Íפʾì¹ç¤Ï¡¢ÄɲäÎ
 | |
| .Xr open 2
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤·¡¢¥Õ¥¡¥¤¥ë¤Ø¤Î°Û¤Ê¤ë¥ª¥Ö¥¸¥§¥¯¥È»²¾È¤ò
 | |
| ÆÀ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
 | |
| ¤³¤Î¤È¤¡¢¿·¤·¤¤¥Õ¥¡¥¤¥ëµ½Ò»Ò¤Î close-on-exec ¥Õ¥é¥°¤ÏÀßÄê²ò½ü¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
 | |
| .Pp
 | |
| .Fn dup2
 | |
| ¤Ë¤Ï¿·¤·¤¤µ½Ò»Ò
 | |
| .Fa newd
 | |
| ¤ÎÃͤò»ØÄꤷ¤Þ¤¹¡£
 | |
| ¤³¤Îµ½Ò»Ò¤¬´û¤Ë»ÈÍѤµ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢
 | |
| .Fa oldd
 | |
| \*(Ne
 | |
| .Fa newd
 | |
| ¤Ç¤¢¤ì¤Ð¡¢¤Þ¤º¤½¤Îµ½Ò»Ò¤Ï
 | |
| .Xr close 2
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬»ÈÍѤµ¤ì¤¿¤«¤Î¤è¤¦¤Ë³ä¤êÅö¤Æ²ò½ü¤µ¤ì¤Þ¤¹¡£
 | |
| .Fa oldd
 | |
| ¤¬Í¸ú¤Êµ½Ò»Ò¤Ç¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
 | |
| .Fa newd
 | |
| ¤Ï¥¯¥í¡¼¥º¤µ¤ì¤Þ¤»¤ó¡£
 | |
| .Fa oldd
 | |
| ==
 | |
| .Fa newd
 | |
| ¤Ç¤¢¤ê¡¢¤·¤«¤â
 | |
| .Fa oldd
 | |
| ¤¬Í¸ú¤Êµ½Ò»Ò¤Î¾ì¹ç¡¢
 | |
| .Fn dup2
 | |
| ¤ÏÀµ¾ï¤Ë½ªÎ»¤·¡¢²¿¤â¤·¤Þ¤»¤ó¡£
 | |
| .Sh Ìá¤êÃÍ
 | |
| ¤¤¤º¤ì¤«¤Î¸Æ¤Ó½Ð¤·¤Ç¥¨¥é¡¼¤¬µ¯¤¤¿¾ì¹ç¤ÏÃÍ -1 ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£
 | |
| ³°ÉôÊÑ¿ô
 | |
| .Va errno
 | |
| ¤Ï¥¨¥é¡¼¤Î¸¶°ø¤ò¼¨¤·¤Þ¤¹¡£
 | |
| .Sh ¥¨¥é¡¼
 | |
| .Fn dup
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤È
 | |
| .Fn dup2
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¼¡¤Î¾ì¹ç¤Ë½èÍý¤Ë¼ºÇÔ¤·¤Þ¤¹:
 | |
| .Bl -tag -width Er
 | |
| .It Bq Er EBADF
 | |
| .Fa oldd
 | |
| ¤Þ¤¿¤Ï
 | |
| .Fa newd
 | |
| °ú¿ô¤¬Í¸ú¤Ê¥¢¥¯¥Æ¥£¥Öµ½Ò»Ò¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
 | |
| .It Bq Er EMFILE
 | |
| ¥¢¥¯¥Æ¥£¥Ö¤Êµ½Ò»Ò¤¬Â¿¤¹¤®¤Þ¤¹¡£
 | |
| .El
 | |
| .Sh ´ØÏ¢¹àÌÜ
 | |
| .Xr accept 2 ,
 | |
| .Xr close 2 ,
 | |
| .Xr fcntl 2 ,
 | |
| .Xr getdtablesize 2 ,
 | |
| .Xr open 2 ,
 | |
| .Xr pipe 2 ,
 | |
| .Xr socket 2 ,
 | |
| .Xr socketpair 2
 | |
| .Sh µ¬³Ê
 | |
| .Fn dup
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤È
 | |
| .Fn dup2
 | |
| ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢
 | |
| .St -p1003.1-90
 | |
| ¤ËŬ¹ç¤·¤Æ¤¤¤Þ¤¹¡£
 | |
| .Sh Îò»Ë
 | |
| .Fn dup
 | |
| ´Ø¿ô¤È
 | |
| .Fn dup2
 | |
| ´Ø¿ô¤Ï
 | |
| .At v7
 | |
| ¤ÇÅо줷¤Þ¤·¤¿¡£
 |