summaryrefslogtreecommitdiffstats
path: root/docs/nspr/reference/pr_getspecialfd.rst
blob: 4cb50fc3c110c50cbeb2fc1bbd0ce9bf3d778ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
PR_GetSpecialFD
===============

Gets the file descriptor that represents the standard input, output, or
error stream.


Syntax
------

.. code::

   #include <prio.h>

   PRFileDesc* PR_GetSpecialFD(PRSpecialFD id);


Parameter
~~~~~~~~~

The function has the following parameter:

``id``
   A pointer to an enumerator of type ``PRSpecialFD``, indicating the
   type of I/O stream desired: ``PR_StandardInput``,
   ``PR_StandardOutput``, or ``PR_StandardError``.


Returns
~~~~~~~

If the ``id`` parameter is valid, :ref:`PR_GetSpecialFD` returns a file
descriptor that represents the corresponding standard I/O stream.
Otherwise, :ref:`PR_GetSpecialFD` returns ``NULL`` and sets the error to
``PR_INVALID_ARGUMENT_ERROR``.


Description
-----------

Type ``PRSpecialFD`` is defined as follows:

.. code::

   typedef enum PRSpecialFD{
      PR_StandardInput,
      PR_StandardOutput,
      PR_StandardError
   } PRSpecialFD;

``#define PR_STDIN PR_GetSpecialFD(PR_StandardInput)``
``#define PR_STDOUT PR_GetSpecialFD(PR_StandardOutput)``
``#define PR_STDERR PR_GetSpecialFD(PR_StandardError)``

File descriptors returned by :ref:`PR_GetSpecialFD` are owned by the
runtime and should not be closed by the caller.