요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media-func-close:
*************
media close()
*************
Name
====
media-close - Close a media device
Synopsis
========
.. code-block:: c
#include <unistd.h>
.. c:function:: int close( int fd )
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
Description
===========
Closes the media device. Resources associated with the file descriptor
are freed. The device configuration remain unchanged.
Return Value
============
:c:func:`close()` returns 0 on success. On error, -1 is returned, and
``errno`` is set appropriately. Possible error codes are:
EBADF
``fd`` is not a valid open file descriptor.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
이름과 선언
1-23이 문서는 GFDL 조건의 `MC` C namespace에서 media device를 닫는 `media-close` operation을 설명합니다.
`<unistd.h>`를 include하고 `int close(int fd)`를 호출합니다.
#include <unistd.h>
int close(int fd);
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media-func-close:
*************
media close()
*************
Name
====
media-close - Close a media device
Synopsis
========
.. code-block:: c
#include <unistd.h>
.. c:function:: int close( int fd )
Argument와 동작
24-35`fd`는 `open()`이 반환한 file descriptor입니다.
`close()`는 media device를 닫고 file descriptor와 연결된 resource를 해제합니다. Device configuration은 바뀌지 않습니다.
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
Description
===========
Closes the media device. Resources associated with the file descriptor
are freed. The device configuration remain unchanged.
반환값과 오류
36-43성공하면 `close()`는 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 알맞게 설정합니다.
`EBADF`는 `fd`가 유효하게 열린 file descriptor가 아님을 뜻합니다.
성공과 오류 contract입니다.
Return Value
============
:c:func:`close()` returns 0 on success. On error, -1 is returned, and
``errno`` is set appropriately. Possible error codes are:
EBADF
``fd`` is not a valid open file descriptor.
요약·해설
media-func-close.rst:1-43`close()`는 descriptor resource를 해제하지만 media device configuration은 변경하지 않습니다. 성공은 0, 유효하지 않은 descriptor는 `EBADF`입니다.