1 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
2 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
3 | .. COMMENT: All rights reserved. |
---|
4 | |
---|
5 | Process Environment Manager |
---|
6 | ########################### |
---|
7 | |
---|
8 | Introduction |
---|
9 | ============ |
---|
10 | |
---|
11 | The process environment manager is responsible for providing the functions |
---|
12 | related to user and group Id management. |
---|
13 | |
---|
14 | The directives provided by the process environment manager are: |
---|
15 | |
---|
16 | - getpid_ - Get Process ID |
---|
17 | |
---|
18 | - getppid_ - Get Parent Process ID |
---|
19 | |
---|
20 | - getuid_ - Get User ID |
---|
21 | |
---|
22 | - geteuid_ - Get Effective User ID |
---|
23 | |
---|
24 | - getgid_ - Get Real Group ID |
---|
25 | |
---|
26 | - getegid_ - Get Effective Group ID |
---|
27 | |
---|
28 | - setuid_ - Set User ID |
---|
29 | |
---|
30 | - setgid_ - Set Group ID |
---|
31 | |
---|
32 | - getgroups_ - Get Supplementary Group IDs |
---|
33 | |
---|
34 | - getlogin_ - Get User Name |
---|
35 | |
---|
36 | - getlogin_r_ - Reentrant Get User Name |
---|
37 | |
---|
38 | - getpgrp_ - Get Process Group ID |
---|
39 | |
---|
40 | - setsid_ - Create Session and Set Process Group ID |
---|
41 | |
---|
42 | - setpgid_ - Set Process Group ID for Job Control |
---|
43 | |
---|
44 | - uname_ - Get System Name |
---|
45 | |
---|
46 | - times_ - Get Process Times |
---|
47 | |
---|
48 | - getenv_ - Get Environment Variables |
---|
49 | |
---|
50 | - setenv_ - Set Environment Variables |
---|
51 | |
---|
52 | - ctermid_ - Generate Terminal Pathname |
---|
53 | |
---|
54 | - ttyname_ - Determine Terminal Device Name |
---|
55 | |
---|
56 | - ttyname_r_ - Reentrant Determine Terminal Device Name |
---|
57 | |
---|
58 | - isatty_ - Determine if File Descriptor is Terminal |
---|
59 | |
---|
60 | - sysconf_ - Get Configurable System Variables |
---|
61 | |
---|
62 | Background |
---|
63 | ========== |
---|
64 | |
---|
65 | Users and Groups |
---|
66 | ---------------- |
---|
67 | |
---|
68 | RTEMS provides a single process, multi-threaded execution environment. In this |
---|
69 | light, the notion of user and group is somewhat without meaning. But RTEMS |
---|
70 | does provide services to provide a synthetic version of user and group. By |
---|
71 | default, a single user and group is associated with the application. Thus |
---|
72 | unless special actions are taken, every thread in the application shares the |
---|
73 | same user and group Id. The initial rationale for providing user and group Id |
---|
74 | functionality in RTEMS was for the filesystem infrastructure to implement file |
---|
75 | permission checks. The effective user/group Id capability has since been used |
---|
76 | to implement permissions checking by the ``ftpd`` server. |
---|
77 | |
---|
78 | In addition to the "real" user and group Ids, a process may have an effective |
---|
79 | user/group Id. This allows a process to function using a more limited |
---|
80 | permission set for certain operations. |
---|
81 | |
---|
82 | User and Group Names |
---|
83 | -------------------- |
---|
84 | |
---|
85 | POSIX considers user and group Ids to be a unique integer that may be |
---|
86 | associated with a name. This is usually accomplished via a file named |
---|
87 | :file:`/etc/passwd` for user Id mapping and :file:`/etc/groups` for group Id |
---|
88 | mapping. Again, although RTEMS is effectively a single process and thus single |
---|
89 | user system, it provides limited support for user and group names. When |
---|
90 | configured with an appropriate filesystem, RTEMS will access the appropriate |
---|
91 | files to map user and group Ids to names. |
---|
92 | |
---|
93 | If these files do not exist, then RTEMS will synthesize a minimal version so |
---|
94 | this family of services return without error. It is important to remember that |
---|
95 | a design goal of the RTEMS POSIX services is to provide useable and meaningful |
---|
96 | results even though a full process model is not available. |
---|
97 | |
---|
98 | Environment Variables |
---|
99 | --------------------- |
---|
100 | |
---|
101 | POSIX allows for variables in the run-time environment. These are name/value |
---|
102 | pairs that make be dynamically set and obtained by programs. In a full POSIX |
---|
103 | environment with command line shell and multiple processes, environment |
---|
104 | variables may be set in one process - such as the shell - and inherited by |
---|
105 | child processes. In RTEMS, there is only one process and thus only one set of |
---|
106 | environment variables across all processes. |
---|
107 | |
---|
108 | Operations |
---|
109 | ========== |
---|
110 | |
---|
111 | Accessing User and Group Ids |
---|
112 | ---------------------------- |
---|
113 | |
---|
114 | The user Id associated with the current thread may be obtain using the |
---|
115 | ``getuid()`` service. Similarly, the group Id may be obtained using the |
---|
116 | ``getgid()`` service. |
---|
117 | |
---|
118 | Accessing Environment Variables |
---|
119 | ------------------------------- |
---|
120 | |
---|
121 | The value associated with an environment variable may be obtained using the |
---|
122 | ``getenv()`` service and set using the ``putenv()`` service. |
---|
123 | |
---|
124 | Directives |
---|
125 | ========== |
---|
126 | |
---|
127 | This section details the process environment manager's directives. A |
---|
128 | subsection is dedicated to each of this manager's directives and describes the |
---|
129 | calling sequence, related constants, usage, and status codes. |
---|
130 | |
---|
131 | .. _getpid: |
---|
132 | |
---|
133 | getpid - Get Process ID |
---|
134 | ----------------------- |
---|
135 | .. index:: getpid |
---|
136 | .. index:: get process id |
---|
137 | |
---|
138 | **CALLING SEQUENCE:** |
---|
139 | |
---|
140 | .. code-block:: c |
---|
141 | |
---|
142 | int getpid( void ); |
---|
143 | |
---|
144 | **STATUS CODES:** |
---|
145 | |
---|
146 | The process Id is returned. |
---|
147 | |
---|
148 | **DESCRIPTION:** |
---|
149 | |
---|
150 | This service returns the process Id. |
---|
151 | |
---|
152 | **NOTES:** |
---|
153 | |
---|
154 | NONE |
---|
155 | |
---|
156 | .. _getppid: |
---|
157 | |
---|
158 | getppid - Get Parent Process ID |
---|
159 | ------------------------------- |
---|
160 | .. index:: getppid |
---|
161 | .. index:: get parent process id |
---|
162 | |
---|
163 | **CALLING SEQUENCE:** |
---|
164 | |
---|
165 | .. code-block:: c |
---|
166 | |
---|
167 | int getppid( void ); |
---|
168 | |
---|
169 | **STATUS CODES:** |
---|
170 | |
---|
171 | The parent process Id is returned. |
---|
172 | |
---|
173 | **DESCRIPTION:** |
---|
174 | |
---|
175 | This service returns the parent process Id. |
---|
176 | |
---|
177 | **NOTES:** |
---|
178 | |
---|
179 | NONE |
---|
180 | |
---|
181 | .. _getuid: |
---|
182 | |
---|
183 | getuid - Get User ID |
---|
184 | -------------------- |
---|
185 | .. index:: getuid |
---|
186 | .. index:: get user id |
---|
187 | |
---|
188 | **CALLING SEQUENCE:** |
---|
189 | |
---|
190 | .. code-block:: c |
---|
191 | |
---|
192 | int getuid( void ); |
---|
193 | |
---|
194 | **STATUS CODES:** |
---|
195 | |
---|
196 | The effective user Id is returned. |
---|
197 | |
---|
198 | **DESCRIPTION:** |
---|
199 | |
---|
200 | This service returns the effective user Id. |
---|
201 | |
---|
202 | **NOTES:** |
---|
203 | |
---|
204 | NONE |
---|
205 | |
---|
206 | .. _geteuid: |
---|
207 | |
---|
208 | geteuid - Get Effective User ID |
---|
209 | ------------------------------- |
---|
210 | .. index:: geteuid |
---|
211 | .. index:: get effective user id |
---|
212 | |
---|
213 | **CALLING SEQUENCE:** |
---|
214 | |
---|
215 | .. code-block:: c |
---|
216 | |
---|
217 | int geteuid( void ); |
---|
218 | |
---|
219 | **STATUS CODES:** |
---|
220 | |
---|
221 | The effective group Id is returned. |
---|
222 | |
---|
223 | **DESCRIPTION:** |
---|
224 | |
---|
225 | This service returns the effective group Id. |
---|
226 | |
---|
227 | **NOTES:** |
---|
228 | |
---|
229 | NONE |
---|
230 | |
---|
231 | .. _getgid: |
---|
232 | |
---|
233 | getgid - Get Real Group ID |
---|
234 | -------------------------- |
---|
235 | .. index:: getgid |
---|
236 | .. index:: get real group id |
---|
237 | |
---|
238 | **CALLING SEQUENCE:** |
---|
239 | |
---|
240 | .. code-block:: c |
---|
241 | |
---|
242 | int getgid( void ); |
---|
243 | |
---|
244 | **STATUS CODES:** |
---|
245 | |
---|
246 | The group Id is returned. |
---|
247 | |
---|
248 | **DESCRIPTION:** |
---|
249 | |
---|
250 | This service returns the group Id. |
---|
251 | |
---|
252 | **NOTES:** |
---|
253 | |
---|
254 | NONE |
---|
255 | |
---|
256 | .. _getegid: |
---|
257 | |
---|
258 | getegid - Get Effective Group ID |
---|
259 | -------------------------------- |
---|
260 | .. index:: getegid |
---|
261 | .. index:: get effective group id |
---|
262 | |
---|
263 | **CALLING SEQUENCE:** |
---|
264 | |
---|
265 | .. code-block:: c |
---|
266 | |
---|
267 | int getegid( void ); |
---|
268 | |
---|
269 | **STATUS CODES:** |
---|
270 | |
---|
271 | The effective group Id is returned. |
---|
272 | |
---|
273 | **DESCRIPTION:** |
---|
274 | |
---|
275 | This service returns the effective group Id. |
---|
276 | |
---|
277 | **NOTES:** |
---|
278 | |
---|
279 | NONE |
---|
280 | |
---|
281 | .. _setuid: |
---|
282 | |
---|
283 | setuid - Set User ID |
---|
284 | -------------------- |
---|
285 | .. index:: setuid |
---|
286 | .. index:: set user id |
---|
287 | |
---|
288 | **CALLING SEQUENCE:** |
---|
289 | |
---|
290 | .. code-block:: c |
---|
291 | |
---|
292 | int setuid( |
---|
293 | uid_t uid |
---|
294 | ); |
---|
295 | |
---|
296 | **STATUS CODES:** |
---|
297 | |
---|
298 | This service returns 0. |
---|
299 | |
---|
300 | **DESCRIPTION:** |
---|
301 | |
---|
302 | This service sets the user Id to ``uid``. |
---|
303 | |
---|
304 | **NOTES:** |
---|
305 | |
---|
306 | NONE |
---|
307 | |
---|
308 | .. _setgid: |
---|
309 | |
---|
310 | setgid - Set Group ID |
---|
311 | --------------------- |
---|
312 | .. index:: setgid |
---|
313 | .. index:: set group id |
---|
314 | |
---|
315 | **CALLING SEQUENCE:** |
---|
316 | |
---|
317 | .. code-block:: c |
---|
318 | |
---|
319 | int setgid( |
---|
320 | gid_t gid |
---|
321 | ); |
---|
322 | |
---|
323 | **STATUS CODES:** |
---|
324 | |
---|
325 | This service returns 0. |
---|
326 | |
---|
327 | **DESCRIPTION:** |
---|
328 | |
---|
329 | This service sets the group Id to ``gid``. |
---|
330 | |
---|
331 | **NOTES:** |
---|
332 | |
---|
333 | NONE |
---|
334 | |
---|
335 | .. _getgroups: |
---|
336 | |
---|
337 | getgroups - Get Supplementary Group IDs |
---|
338 | --------------------------------------- |
---|
339 | .. index:: getgroups |
---|
340 | .. index:: get supplementary group ids |
---|
341 | |
---|
342 | **CALLING SEQUENCE:** |
---|
343 | |
---|
344 | .. code-block:: c |
---|
345 | |
---|
346 | int getgroups( |
---|
347 | int gidsetsize, |
---|
348 | gid_t grouplist[] |
---|
349 | ); |
---|
350 | |
---|
351 | **STATUS CODES:** |
---|
352 | |
---|
353 | NA |
---|
354 | |
---|
355 | **DESCRIPTION:** |
---|
356 | |
---|
357 | This service is not implemented as RTEMS has no notion of supplemental groups. |
---|
358 | |
---|
359 | **NOTES:** |
---|
360 | |
---|
361 | If supported, this routine would only be allowed for the super-user. |
---|
362 | |
---|
363 | .. _getlogin: |
---|
364 | |
---|
365 | getlogin - Get User Name |
---|
366 | ------------------------ |
---|
367 | .. index:: getlogin |
---|
368 | .. index:: get user name |
---|
369 | |
---|
370 | **CALLING SEQUENCE:** |
---|
371 | |
---|
372 | .. code-block:: c |
---|
373 | |
---|
374 | char *getlogin( void ); |
---|
375 | |
---|
376 | **STATUS CODES:** |
---|
377 | |
---|
378 | Returns a pointer to a string containing the name of the current user. |
---|
379 | |
---|
380 | **DESCRIPTION:** |
---|
381 | |
---|
382 | This routine returns the name of the current user. |
---|
383 | |
---|
384 | **NOTES:** |
---|
385 | |
---|
386 | This routine is not reentrant and subsequent calls to ``getlogin()`` will |
---|
387 | overwrite the same buffer. |
---|
388 | |
---|
389 | .. _getlogin_r: |
---|
390 | |
---|
391 | getlogin_r - Reentrant Get User Name |
---|
392 | ------------------------------------ |
---|
393 | .. index:: getlogin_r |
---|
394 | .. index:: reentrant get user name |
---|
395 | .. index:: get user name, reentrant |
---|
396 | |
---|
397 | **CALLING SEQUENCE:** |
---|
398 | |
---|
399 | .. code-block:: c |
---|
400 | |
---|
401 | int getlogin_r( |
---|
402 | char *name, |
---|
403 | size_t namesize |
---|
404 | ); |
---|
405 | |
---|
406 | **STATUS CODES:** |
---|
407 | |
---|
408 | .. list-table:: |
---|
409 | :class: rtems-table |
---|
410 | |
---|
411 | * - ``EINVAL`` |
---|
412 | - The arguments were invalid. |
---|
413 | |
---|
414 | **DESCRIPTION:** |
---|
415 | |
---|
416 | This is a reentrant version of the ``getlogin()`` service. The caller |
---|
417 | specified their own buffer, ``name``, as well as the length of this buffer, |
---|
418 | ``namesize``. |
---|
419 | |
---|
420 | **NOTES:** |
---|
421 | |
---|
422 | NONE |
---|
423 | |
---|
424 | .. _getpgrp: |
---|
425 | |
---|
426 | getpgrp - Get Process Group ID |
---|
427 | ------------------------------ |
---|
428 | .. index:: getpgrp |
---|
429 | .. index:: get process group id |
---|
430 | |
---|
431 | **CALLING SEQUENCE:** |
---|
432 | |
---|
433 | .. code-block:: c |
---|
434 | |
---|
435 | pid_t getpgrp( void ); |
---|
436 | |
---|
437 | **STATUS CODES:** |
---|
438 | |
---|
439 | The procress group Id is returned. |
---|
440 | |
---|
441 | **DESCRIPTION:** |
---|
442 | |
---|
443 | This service returns the current progress group Id. |
---|
444 | |
---|
445 | **NOTES:** |
---|
446 | |
---|
447 | This routine is implemented in a somewhat meaningful way for RTEMS but is truly |
---|
448 | not functional. |
---|
449 | |
---|
450 | .. _setsid: |
---|
451 | |
---|
452 | setsid - Create Session and Set Process Group ID |
---|
453 | ------------------------------------------------ |
---|
454 | .. index:: setsid |
---|
455 | .. index:: create session and set process group id |
---|
456 | |
---|
457 | **CALLING SEQUENCE:** |
---|
458 | |
---|
459 | .. code-block:: c |
---|
460 | |
---|
461 | pid_t setsid( void ); |
---|
462 | |
---|
463 | **STATUS CODES:** |
---|
464 | |
---|
465 | .. list-table:: |
---|
466 | :class: rtems-table |
---|
467 | |
---|
468 | * - ``EPERM`` |
---|
469 | - The application does not have permission to create a process group. |
---|
470 | |
---|
471 | **DESCRIPTION:** |
---|
472 | |
---|
473 | This routine always returns ``EPERM`` as RTEMS has no way to create new |
---|
474 | processes and thus no way to create a new process group. |
---|
475 | |
---|
476 | **NOTES:** |
---|
477 | |
---|
478 | NONE |
---|
479 | |
---|
480 | .. _setpgid: |
---|
481 | |
---|
482 | setpgid - Set Process Group ID for Job Control |
---|
483 | ---------------------------------------------- |
---|
484 | .. index:: setpgid |
---|
485 | .. index:: set process group id for job control |
---|
486 | |
---|
487 | **CALLING SEQUENCE:** |
---|
488 | |
---|
489 | .. code-block:: c |
---|
490 | |
---|
491 | int setpgid( |
---|
492 | pid_t pid, |
---|
493 | pid_t pgid |
---|
494 | ); |
---|
495 | |
---|
496 | **STATUS CODES:** |
---|
497 | |
---|
498 | .. list-table:: |
---|
499 | :class: rtems-table |
---|
500 | |
---|
501 | * - ``ENOSYS`` |
---|
502 | - The routine is not implemented. |
---|
503 | |
---|
504 | **DESCRIPTION:** |
---|
505 | |
---|
506 | This service is not implemented for RTEMS as process groups are not supported. |
---|
507 | |
---|
508 | **NOTES:** |
---|
509 | |
---|
510 | NONE |
---|
511 | |
---|
512 | .. _uname: |
---|
513 | |
---|
514 | uname - Get System Name |
---|
515 | ----------------------- |
---|
516 | .. index:: uname |
---|
517 | .. index:: get system name |
---|
518 | |
---|
519 | **CALLING SEQUENCE:** |
---|
520 | |
---|
521 | .. code-block:: c |
---|
522 | |
---|
523 | int uname( |
---|
524 | struct utsname \*name |
---|
525 | ); |
---|
526 | |
---|
527 | **STATUS CODES:** |
---|
528 | |
---|
529 | .. list-table:: |
---|
530 | :class: rtems-table |
---|
531 | |
---|
532 | * - ``EPERM`` |
---|
533 | - The provided structure pointer is invalid. |
---|
534 | |
---|
535 | **DESCRIPTION:** |
---|
536 | |
---|
537 | This service returns system information to the caller. It does this by filling |
---|
538 | in the ``struct utsname`` format structure for the caller. |
---|
539 | |
---|
540 | **NOTES:** |
---|
541 | |
---|
542 | The information provided includes the operating system (RTEMS in all |
---|
543 | configurations), the node number, the release as the RTEMS version, and the CPU |
---|
544 | family and model. The CPU model name will indicate the multilib executive |
---|
545 | variant being used. |
---|
546 | |
---|
547 | .. _times: |
---|
548 | |
---|
549 | times - Get process times |
---|
550 | ------------------------- |
---|
551 | .. index:: times |
---|
552 | .. index:: get process times |
---|
553 | |
---|
554 | **CALLING SEQUENCE:** |
---|
555 | |
---|
556 | .. code-block:: c |
---|
557 | |
---|
558 | #include <sys/time.h> |
---|
559 | clock_t times( |
---|
560 | struct tms *ptms |
---|
561 | ); |
---|
562 | |
---|
563 | **STATUS CODES:** |
---|
564 | |
---|
565 | This routine returns the number of clock ticks that have elapsed since the |
---|
566 | system was initialized (e.g. the application was started). |
---|
567 | |
---|
568 | **DESCRIPTION:** |
---|
569 | |
---|
570 | ``times`` stores the current process times in ``ptms``. The format of ``struct |
---|
571 | tms`` is as defined in ``<sys/times.h>``. RTEMS fills in the field |
---|
572 | ``tms_utime`` with the number of ticks that the calling thread has executed and |
---|
573 | the field ``tms_stime`` with the number of clock ticks since system boot (also |
---|
574 | returned). All other fields in the ``ptms`` are left zero. |
---|
575 | |
---|
576 | **NOTES:** |
---|
577 | |
---|
578 | RTEMS has no way to distinguish between user and system time so this routine |
---|
579 | returns the most meaningful information possible. |
---|
580 | |
---|
581 | .. _getenv: |
---|
582 | |
---|
583 | getenv - Get Environment Variables |
---|
584 | ---------------------------------- |
---|
585 | .. index:: getenv |
---|
586 | .. index:: get environment variables |
---|
587 | |
---|
588 | **CALLING SEQUENCE:** |
---|
589 | |
---|
590 | .. code-block:: c |
---|
591 | |
---|
592 | char *getenv( |
---|
593 | const char \*name |
---|
594 | ); |
---|
595 | |
---|
596 | **STATUS CODES:** |
---|
597 | |
---|
598 | .. list-table:: |
---|
599 | :class: rtems-table |
---|
600 | |
---|
601 | * - ``NULL`` |
---|
602 | - when no match |
---|
603 | * - `pointer to value` |
---|
604 | - when successful |
---|
605 | |
---|
606 | **DESCRIPTION:** |
---|
607 | |
---|
608 | This service searches the set of environment variables for a string that |
---|
609 | matches the specified ``name``. If found, it returns the associated value. |
---|
610 | |
---|
611 | **NOTES:** |
---|
612 | |
---|
613 | The environment list consists of name value pairs that are of the form ``name = |
---|
614 | value``. |
---|
615 | |
---|
616 | .. _setenv: |
---|
617 | |
---|
618 | setenv - Set Environment Variables |
---|
619 | ---------------------------------- |
---|
620 | .. index:: setenv |
---|
621 | .. index:: set environment variables |
---|
622 | |
---|
623 | **CALLING SEQUENCE:** |
---|
624 | |
---|
625 | .. code-block:: c |
---|
626 | |
---|
627 | int setenv( |
---|
628 | const char *name, |
---|
629 | const char *value, |
---|
630 | int overwrite |
---|
631 | ); |
---|
632 | |
---|
633 | **STATUS CODES:** |
---|
634 | |
---|
635 | Returns 0 if successful and -1 otherwise. |
---|
636 | |
---|
637 | **DESCRIPTION:** |
---|
638 | |
---|
639 | This service adds the variable ``name`` to the environment with ``value``. If |
---|
640 | ``name`` is not already exist, then it is created. If ``name`` exists and |
---|
641 | ``overwrite`` is zero, then the previous value is not overwritten. |
---|
642 | |
---|
643 | **NOTES:** |
---|
644 | |
---|
645 | NONE |
---|
646 | |
---|
647 | .. _ctermid: |
---|
648 | |
---|
649 | ctermid - Generate Terminal Pathname |
---|
650 | ------------------------------------ |
---|
651 | .. index:: ctermid |
---|
652 | .. index:: generate terminal pathname |
---|
653 | |
---|
654 | **CALLING SEQUENCE:** |
---|
655 | |
---|
656 | .. code-block:: c |
---|
657 | |
---|
658 | char *ctermid( |
---|
659 | char *s |
---|
660 | ); |
---|
661 | |
---|
662 | **STATUS CODES:** |
---|
663 | |
---|
664 | Returns a pointer to a string indicating the pathname for the controlling |
---|
665 | terminal. |
---|
666 | |
---|
667 | **DESCRIPTION:** |
---|
668 | |
---|
669 | This service returns the name of the terminal device associated with this |
---|
670 | process. If ``s`` is NULL, then a pointer to a static buffer is returned. |
---|
671 | Otherwise, ``s`` is assumed to have a buffer of sufficient size to contain the |
---|
672 | name of the controlling terminal. |
---|
673 | |
---|
674 | **NOTES:** |
---|
675 | |
---|
676 | By default on RTEMS systems, the controlling terminal is :file:`/dev/console`. |
---|
677 | Again this implementation is of limited meaning, but it provides true and |
---|
678 | useful results which should be sufficient to ease porting applications from a |
---|
679 | full POSIX implementation to the reduced profile supported by RTEMS. |
---|
680 | |
---|
681 | .. _ttyname: |
---|
682 | |
---|
683 | ttyname - Determine Terminal Device Name |
---|
684 | ---------------------------------------- |
---|
685 | .. index:: ttyname |
---|
686 | .. index:: determine terminal device name |
---|
687 | |
---|
688 | **CALLING SEQUENCE:** |
---|
689 | |
---|
690 | .. code-block:: c |
---|
691 | |
---|
692 | char *ttyname( |
---|
693 | int fd |
---|
694 | ); |
---|
695 | |
---|
696 | **STATUS CODES:** |
---|
697 | |
---|
698 | Pointer to a string containing the terminal device name or ``NULL`` is returned |
---|
699 | on any error. |
---|
700 | |
---|
701 | **DESCRIPTION:** |
---|
702 | |
---|
703 | This service returns a pointer to the pathname of the terminal device that is |
---|
704 | open on the file descriptor ``fd``. If ``fd`` is not a valid descriptor for a |
---|
705 | terminal device, then NULL is returned. |
---|
706 | |
---|
707 | **NOTES:** |
---|
708 | |
---|
709 | This routine uses a static buffer. |
---|
710 | |
---|
711 | .. _ttyname_r: |
---|
712 | |
---|
713 | ttyname_r - Reentrant Determine Terminal Device Name |
---|
714 | ---------------------------------------------------- |
---|
715 | .. index:: ttyname_r |
---|
716 | .. index:: reentrant determine terminal device name |
---|
717 | |
---|
718 | **CALLING SEQUENCE:** |
---|
719 | |
---|
720 | .. code-block:: c |
---|
721 | |
---|
722 | int ttyname_r( |
---|
723 | int fd, |
---|
724 | char *name, |
---|
725 | int namesize |
---|
726 | ); |
---|
727 | |
---|
728 | **STATUS CODES:** |
---|
729 | |
---|
730 | This routine returns -1 and sets ``errno`` as follows: |
---|
731 | |
---|
732 | .. list-table:: |
---|
733 | :class: rtems-table |
---|
734 | |
---|
735 | * - ``EBADF`` |
---|
736 | - If not a valid descriptor for a terminal device. |
---|
737 | * - ``EINVAL`` |
---|
738 | - If ``name`` is ``NULL`` or ``namesize`` are insufficient. |
---|
739 | |
---|
740 | **DESCRIPTION:** |
---|
741 | |
---|
742 | This service the pathname of the terminal device that is open on the file |
---|
743 | descriptor ``fd``. |
---|
744 | |
---|
745 | **NOTES:** |
---|
746 | |
---|
747 | NONE |
---|
748 | |
---|
749 | .. _isatty: |
---|
750 | |
---|
751 | isatty - Determine if File Descriptor is Terminal |
---|
752 | ------------------------------------------------- |
---|
753 | .. index:: isatty |
---|
754 | .. index:: determine if file descriptor is terminal |
---|
755 | |
---|
756 | **CALLING SEQUENCE:** |
---|
757 | |
---|
758 | .. code-block:: c |
---|
759 | |
---|
760 | int isatty( |
---|
761 | int fd |
---|
762 | ); |
---|
763 | |
---|
764 | **STATUS CODES:** |
---|
765 | |
---|
766 | Returns 1 if ``fd`` is a terminal device and 0 otherwise. |
---|
767 | |
---|
768 | **DESCRIPTION:** |
---|
769 | |
---|
770 | This service returns 1 if ``fd`` is an open file descriptor connected to a |
---|
771 | terminal and 0 otherwise. |
---|
772 | |
---|
773 | **NOTES:** |
---|
774 | |
---|
775 | .. _sysconf: |
---|
776 | |
---|
777 | sysconf - Get Configurable System Variables |
---|
778 | ------------------------------------------- |
---|
779 | .. index:: sysconf |
---|
780 | .. index:: get configurable system variables |
---|
781 | |
---|
782 | **CALLING SEQUENCE:** |
---|
783 | |
---|
784 | .. code-block:: c |
---|
785 | |
---|
786 | long sysconf( |
---|
787 | int name |
---|
788 | ); |
---|
789 | |
---|
790 | **STATUS CODES:** |
---|
791 | |
---|
792 | The value returned is the actual value of the system resource. If the |
---|
793 | requested configuration name is a feature flag, then 1 is returned if the |
---|
794 | available and 0 if it is not. On any other error condition, -1 is returned. |
---|
795 | |
---|
796 | **DESCRIPTION:** |
---|
797 | |
---|
798 | This service is the mechanism by which an application determines values for |
---|
799 | system limits or options at runtime. |
---|
800 | |
---|
801 | **NOTES:** |
---|
802 | |
---|
803 | Much of the information that may be obtained via ``sysconf`` has equivalent |
---|
804 | macros in ``unistd.h``. However, those macros reflect conservative limits |
---|
805 | which may have been altered by application configuration. |
---|