Advanced Programming in the UNIX Environment: Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Advanced Programming in the UNIX Environment: Second Edition [Electronic resources] - نسخه متنی

W. Richard Stevens; Stephen A. Rago

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



9.7. tcgetpgrp, tcsetpgrp, and tcgetsid Functions


We need a way to tell the kernel which process group is the foreground process group, so that the terminal device driver knows where to send the terminal input and the terminal-generated signals (Figure 9.7).

#include <unistd.h>
pid_t tcgetpgrp(int

filedes );

Returns: process group ID of foreground process group if OK, 1 on error

int tcsetpgrp(int

filedes , pid_t

pgrpid );

Returns: 0 if OK, 1 on error

The function tcgetpgrp returns the process group ID of the foreground process group associated with the terminal open on

filedes .

If the process has a controlling terminal, the process can call tcsetpgrp to set the foreground process group ID to

pgrpid . The value of

pgrpid must be the process group ID of a process group in the same session, and

filedes must refer to the controlling terminal of the session.

Most applications don't call these two functions directly. They are normally called by job-control shells.

The Single UNIX Specification defines an XSI extension called tcgetsid to allow an application to obtain the process group ID for the session leader given a file descriptor for the controlling TTY.

#include <termios.h>
pid_t tcgetsid(int

filedes );

Returns: session leader's process group ID if OK, 1 on error

Applications that need to manage controlling terminals can use tcgetsid to identify the session ID of the controlling terminal's session leader (which is equivalent to the session leader's process group ID).


    / 369