Add Book to My BookshelfPurchase This Book Online

Chapter 11 - Processes

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

Porting Notes
In BSD-based versions of UNIX, the getpgrp function accepts a process ID as an argument, and returns the process group of that process. In SVR4, this can be accomplished by using the getpgid function:
    #include <sys/types.h>
    #include <unistd.h>
    pid_t getpgid(pid_t pid);
BSD UNIX provides functions called getpriority and setpriority to get and set the priorities (nice values) of processes. There is no direct replacement for these functions in SVR4, although the priocntl function supplies much of the same functionality.
The wait3 function offered by BSD UNIX is not present in SVR4 (except in the compatibility library). Its functionality can mostly be provided by waitpid, except that waitpid will not return resource usage statistics as wait3 does.
The BSD killpg function, which sends a signal to a process group, can be replaced with a call to the kill function, specifying the process group ID as a negative number.
Calls to the BSD setpgrp function should be replaced with calls to setsid. Note that other changes will probably be necessary, since all versions of Berkley UNIX prior to 4.4BSD do not offer POSIX sessions.
In BSD UNIX, a process disassociated itself from the controlling terminal with the following code sequence:
    ·
    ·
    ·
    pid = fork();
    if (pid == 0) {
        if ((fd = open("/dev/tty", 0)) >= 0) {
            ioctl(fd, TIOCNOTTY, 0);
            close(fd);
        }
        ·
        ·
        ·
    }
    ·
    ·
    ·
In the POSIX environment, this should be replaced with a call to setsid:
    ·
    ·
    ·
    pid = fork();
    if (pid == 0) {
        setsid();
        ·
        ·
        ·
    }
    ·
    ·
    ·
The BSD implementation of times returns times in units of 1/HZ seconds, where HZ is defined in the include file sys/param.h.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback