Browse Prior Art Database

Algorithm to Support the Emulation of UNIX Kill() System Call in OS/2

IP.com Disclosure Number: IPCOM000114678D
Original Publication Date: 1995-Jan-01
Included in the Prior Art Database: 2005-Mar-29
Document File: 4 page(s) / 94K

Publishing Venue

IBM

Related People

Hidalgo, DS: AUTHOR [+2]

Abstract

Disclosed is an invention which provides an algorithm that can be used to obtain a very close emulation of the kill() function in OS/2*. The emulation of UNIX** system calls is an accepted approach to porting UNIX C source code to OS/2. The differences between these two operating systems makes the emulation of some UNIX system calls particularly challenging. The kill() function used in UNIX to send inter-process signals is one of these.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 54% of the total text.

Algorithm to Support the Emulation of UNIX Kill() System Call in OS/2

      Disclosed is an invention which provides an algorithm that can
be used to obtain a very close emulation of the kill() function in
OS/2*.  The emulation of UNIX** system calls is an accepted approach
to porting UNIX C source code to OS/2.  The differences between these
two operating systems makes the emulation of some UNIX system calls
particularly challenging.  The kill() function used in UNIX to send
inter-process signals is one of these.

      An approach used to port program code written for UNIX
platforms to other operating systems such as OS/2 is to emulate the
UNIX system calls in those operating systems, along with all the
necessary semantics of those calls and the necessary header file
definitions expected by the ported source code.  Some UNIX system
calls are easier to emulate in OS/2 than others.  Of particular
interest is the emulation of the UNIX kill() system call.  This
function used to send signals from one process to another has no
equivalent in OS/2.

      This invention provides an algorithm that can be used to obtain
a very close OS/2 emulation of UNIX kill() system call that is used
to send signals from process to another, or to detect if a given
process exists (i.e., the kill(pid,0) call).  This algorithm is also
based on a separately published process state tracking facility that
allows this emulation to access information about the process
indicated by the pid parameter.

The detailed algorithm for an OS/2 emulation of the UNIX kill()
system call is shown below.
  int kill(pid_t pid, int sig) BEGIN
    IF The value of the sig parameter is equal to zero THEN
  BEGIN
    Call the process state tracking facility API
      dceos2_get_process_state(), passing in the address of the pid
      parameter.
    IF the value returned by the above function call is equal to the
      symbolic constant DCEOS2_PROCESS_NONE THEN
    BEGIN
      Set the value of errno to ESRCH.
      Return -1.
    END
    ELSE Return 0.
  END
  ELSE IF The value of the sig parameter is equal to SIGTERM
      or SIGKILL THEN
  BEGIN
    Call the OS/2 DosKillProcess() to kill the process whose ID is
      indicated by the pid parameter.
    IF the above call returns an error THEN
    BEGIN
      Set the value of errno to EINVAL.
      Return -1.
    END
    ELSE Return 0.
  END
  ELSE IF The value of the sig parameter is equal to...