[comp.os.os2.programmer] questions on os/2

yeh@ubvax.UB.Com (David Yeh) (03/29/91)

Hi,
   I am a new OS/2 programmer, and I have two questions here:

   1. Is there any way to kill an OS/2 process which is currently blocking?
      I have tried the following methods but they all failed:
      a. close the window;
      b. using "kill" in ps utility;
      c. using DosKillProcess().

   2. Is there any function calls in OS/2 performing exactly the same
      functionality as "fork()" does in UNIX? I have used DosExecPgm(),
      spawn(), but the child process they created did not really inherit
      everything its parent process has.

      Thanks a lot,

      David

ibmman@eng.clemson.edu ((the) IBMMAN) (03/29/91)

From article <39443@ubvax.UB.Com>, by yeh@ubvax.UB.Com (David Yeh):
>    1. Is there any way to kill an OS/2 process which is currently blocking?
>       I have tried the following methods but they all failed:
>       a. close the window;
>       b. using "kill" in ps utility;
>       c. using DosKillProcess().

We have a utility called KILL.EXE which simply calls DosKillProcess.  It
has never failed for me.

>    2. Is there any function calls in OS/2 performing exactly the same
>       functionality as "fork()" does in UNIX? I have used DosExecPgm(),
>       spawn(), but the child process they created did not really inherit
>       everything its parent process has.

I have never heard of one, and I think it would be extremely difficult to
write one due to the fact that there can be multiple data segments.  I'm
not typically a Unix programmer, but if I recall properly (correct me if I'm
wrong) fork()'s children inherit everything from the parent including their
very own copy of the data block (and if you order now, we'll throw in a
free disk pack... ;) .

Cheers,
Q

thierry@watson.ibm.com (Thierry Samama) (04/01/91)

In <1991Mar29.141629.9239@hubcap.clemson.edu>, ibmman@eng.clemson.edu ((the) IBMMAN) writes:
>
>We have a utility called KILL.EXE which simply calls DosKillProcess.  It
>has never failed for me.
>

DosKillProcess only "flags the process to terminate", according to the
OS/2 1.2 CP Reference. So if the process has set a signal handler for
SIGTERM (using DosSetSigHandler) and the signal handler refuses to yield,
the process will not terminate. To the best of my knowledge, there is no way
to work around this.

-----------------------------------------------------------------------------
Thierry Samama      (914) 945-2282      SAMAMA at YKTVMZ       samama@ibm.com
IBM T.J. Watson Research Center,   PO Box 218,   Yorktown Heights,   NY 10598
-----------------------------------------------------------------------------

GD.SAR@forsythe.stanford.edu (Sandy Rockowitz) (04/02/91)

In article <1991Apr1.153428.13292@watson.ibm.com>,
thierry@watson.ibm.com (Thierry Samama) writes:
>
>DosKillProcess only "flags the process to terminate", according to the
>OS/2 1.2 CP Reference. So if the process has set a signal handler for
>SIGTERM (using DosSetSigHandler) and the signal handler refuses to yield,
>the process will not terminate. To the best of my knowledge, there is no way
>to work around this.
>

Regarding the use of signals and termination, I've been having
difficulty separating process termination (SIGTERM) from
Ctrl-Break (SIGBREAK).  If I register a signal handler for
Ctrl-Break and Ctrl-C using DosSetSigHandler, that process
receives termination requests (e.g. geneated by the End Task
button on the Task Manager), and these are marked to my
signal handler as being Ctrl-Break, not process termination.

This was happening under EE 1.2.  Haven't yet retested under 1.3.

Sandy Rockowitz
gd.sar@forsythe.stanford.edu