Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ process_management(3K) — DG/UX R4.11MU05

Media Vault

Software Library

Restoration Projects

Artifacts Sought



process_management(3K)         DG/UX R4.11MU05        process_management(3K)


NAME
       processmanagement: pmgetmypid, pmgetmypgid,
       hdlgetmyprocesshandle, pcisinterrupted, pcisterminated,
       sigkernelsendtoprocessgroupid, sigkernelsendtoprocess -
       manage processes and signals

SYNOPSIS
       #include "/usr/src/uts/aviion/ii/ipm.h"
       #include "/usr/src/uts/aviion/ii/ipc.h"
       #include "/usr/src/uts/aviion/ii/isig.h"
       #include "/usr/src/uts/aviion/ii/ihdl.h"


       gidt              pmgetmypgid (void)

       pidt              pmgetmypid (void)

       hdlprocesshandletype  hdlgetmyprocesshandle (void)

       booleantype        pcisinterrupted (vpeventptrtype eventptr)

       booleantype        pcisterminated (vpeventptrtype eventptr)

       void                sigkernelsendtoprocessgroupid (pidt
                           targetgroup, sigsignalnumbertype
                           signalnumber)

       void                sigkernelsendtoprocess
                           (hdlprocesshandletype targethandle,
                           sigsignalnumbertype signalnumber)

   where:
       eventptr     The address of a LWP's interrupt event.
       handle        The subject process' handle.
       processgroup The process group ID of the target process group.
       processid    The process ID of the target process.
       signalnumber The number of the signal being sent.

DESCRIPTION
       The following routines are described in this man page:
       pmgetmypid                Return process ID of the calling LWP's
                                    process
       pmgetmypgid               Return calling LWP's process group
       hdlgetmyprocesshandle    Return the calling LWP's process handle
       pcisinterrupted            Check for any unblocked signal that
                                    needs to be handled during a system call
       pcisterminated             Check for unblocked termination signals
                                    during a system call
       sigkernelsendtoprocessgroupid
                                    Send a signal to a process group
       sigkernelsendtoprocess   Send signal to process identified by PID

   Overview to Using Process Signal Management Routines
       The DG/UX kernel allows you to send a signal to either a particular
       process or to a group of processes.  You can send signals selectively
       based on the target process': 1) process handle; or 2) process group
       (PGID).  The routines you use are: sigkernelsendtoprocess, and
       sigkernelsendtoprocessgroupid.  In the DG/UX kernel, it is more
       efficient and reliable to refer to processes by their process handle
       than by their PID.  Hence, signaling by sigkernelsendtoprocess is
       the preferred method.

       Typically you will be sending signals to your own process or other
       processes in your process group, and you will need the appropriate
       process identifier.  You can determine you own PID and PGID by call­
       ing pmgetmypid or pmgetmypgid, respectively.  You can determine
       your own process handle by calling hdlgetmyprocesshandle.

       You must query the kernel to find out if you have a signal pending.
       You query for any pending signals using the pcisinterrupted and
       pcisterminated routines.

       The kernel identifies two classes of signals: normal ones that the
       calling LWP can handle; and terminal ones that will cause the calling
       LWP's process to terminate (with or without a core dump).  You call
       pcisinterrupted to query about both normal and terminate signals.
       You call pcisterminated to query about terminate signals only.

       The DG/UX kernel implements signals as software interrupts.  The
       query routine (for example, pcisinterrupted) returns TRUE if the
       LWP has an signal pending that needs to be handled.  If a signal is
       not present, the routine returns FALSE and returns an interruption
       event to await.  You can use this event to suspend and wait for a
       signal to interrupt the LWP.  To do so you add the event to the list
       of events to be awaited and call vpawaitec.  If the interruption
       event is satisfied, you should verify that a signal has occurred by
       calling the query routine again.

       Note that pcisinterrupted may internally suspend the calling LWP
       for an arbitrary amount of time and should only be used when an in­
       definite wait is possible.  For example, if a process that is being
       debugged receives a signal, it will communicate with its debugger
       during pcisinterrupted (see ptrace(2)).  Because of this,
       pcisinterrupted may pend indefinitely waiting for a debugger to
       continue the calling LWP's process.  Because it may pend indefinite­
       ly, you should avoid holding locks when calling pcisinterrupted.

       pcisterminated is designed for use within the kernel when a poten­
       tially long, but nevertheless finite length operation is started.
       For example, a space operation on a tape drive or an I/O request to
       an NFS server are such potentially long operations.  In either case
       the operation will eventually finish (possibly due to a time-out),
       but the user may like the option to terminate the operation mid-
       stream by sending the process a signal.  pcisterminated does not
       communicate with any debugger process and does not flag non-terminal
       signals.  Because it only informs the caller of terminal signals, you
       can safely call it while holding a lock.

   Constants and Data Structures
       This subsection describes constants and data structures defined in
       the include files cited in the SYNOPSIS section and used by the rou­
       tines documented in this man page.

       Try to avoid dependencies on the specifics of these structures, such
       as size or location of fields, because these specifics may change in
       later releases of the software.  You can verify exact variable defi­
       nitions in the appropriate include file.  The best way to avoid such
       dependencies is to use kernel-supplied routines to manipulate these
       structures.

   pmgetmypgid
       This routine returns the process group of the calling LWP.

   pmgetmypid
       This routine returns the process id of the calling LWP.

   hdlgetmyprocesshandle
       This routine returns the process handle of the calling LWP.

   pcisinterrupted
       This routine returns if the LWP is interrupted by a signal.  It
       should be used whenever a system call will pend the calling LWP until
       some external event occurs (that is, pend for an arbitrary amount of
       time).  Processing includes the following:

          ·   Interrupting the system call.

          ·   Terminating the process (with or without a core dump).

          ·   Stopping the process for an arbitrary amount of time.

       Only the last of these actions is contained entirely within the
       pcisinterrupted routine.  The first two actions are performed in
       cooperation with the caller.

       Typically, you will use the following code fragment:

              if (pcisinterrupted(&events[LWPINTERRUPT]))
              {
              Arrange to return EINTR to the user.  Exit with error EINTR.
              }
              vpawaitec(events, N, &index);
              Act on the event that was satisfied.
              If only the LWP_INTERRUPT was satisfied, loop back to
              pcisinterrupted().

       In the code shown above, the relevant events are those in the
       events[] array in the first line.  If the calling LWP is interrupted
       pcisinterrupted will return TRUE and the system call will return an
       error and will set errno to EINTR.  Otherwise, pcisinterrupted will
       return FALSE and will return in events[LWPINTERRUPT] the event to
       await for the LWP to be interrupted.  The system call pends until the
       calling LWP is interrupted or one of the relevant events has hap­
       pened.  If only the LWP_INTERRUPT event was satisfied, then loop back
       to pcisinterrupted to verify the LWP was interrupted.

   pcisterminated
       This routine checks for termination signals during a system call.

       This routine determines whether the calling LWP has any signals that
       will cause process termination.

       This call is designed for use within the kernel when a potentially
       long but nevertheless finite operation is started.  For example, a
       spacing operation on a tape drive or an I/O request to an NFS server
       is essentially indefinite.  In both of these cases, the operation is
       guaranteed to eventually finish, perhaps due to a timeout; but the
       end user may like the option of terminating the operation mid-stream
       by sending the process a signal.

   sigkernelsendtoprocessgroupid
       This routine sends a signal to a process group.

       The routine sends the signal signalnumber to the processes whose
       process group ID is processgroup.  The signal is sent only to pro­
       cesses that are not system processes and to which the calling LWP has
       permission to send a signal.

   sigkernelsendtoprocess
       If the subject process exists, this routine sends the process a sig­
       nal. If the subject process does not exist, this routine has no ef­
       fect. The current process handle is acquired using
       hdlgetmyprocesshandle.

DIAGNOSTICS
   Return Value
       For pmgetmypgid: the process group.

       For pmgetmypid: the process id.

       For hdlgetmyprocesshandle: the process handle.

       For pcisinterrupted and pcisterminated:
              TRUE   A signal is presented to be handled.
              FALSE  No signal is present.  eventptr is set to an event
                     that will occur when it is appropriate to re-check for
                     termination signals.

   Errors
       None.

   Abort Conditions
       None.

SEE ALSO
       pmissuperuser(3K).
       Programming in the DG/UX Kernel Environment.


Licensed material--property of copyright holder(s)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026