en:docs:fapi:dosexit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:docs:fapi:dosexit [2018/08/26 09:05] prokusheven:docs:fapi:dosexit [2021/09/17 13:41] (current) prokushev
Line 1: Line 1:
-{{logos:os2.gif?35x35}} {{logos:dos.gif?35x35}}+{{page>en:templates:fapiint}} 
 ====== DosExit ====== ====== DosExit ======
  
 This call is issued when a thread completes executing. The current thread or process ends. This call is issued when a thread completes executing. The current thread or process ends.
  
-==Syntax== +===== Syntax ===== 
- DosExit (ActionCode, ResultCode)+<code c> 
 +DosExit (ActionCode, ResultCode) 
 +</code>
  
-==Parameters==+===== Parameters =====
  
-  *ActionCode (USHORT) - input : Terminates the process and all its threads.+ 
 +  *ActionCode ([[USHORT]]) - input : Terminates the process and all its threads.
  
 ^ Value ^ Definition ^ ^ Value ^ Definition ^
Line 15: Line 19:
 | 1 | All threads in the process end. | | 1 | All threads in the process end. |
  
-  *ResultCode (USHORT) - input : Program's completion code. It is passed to any thread that issues DosCwait for this process.+  *ResultCode ([[USHORT]]) - input : Program's completion code. It is passed to any thread that issues DosCwait for this process. 
 + 
 +===== Remarks =====
  
-==Remarks== 
 DosExit allows a thread to terminate itself or be terminated by another thread in its process. If ActionCode=0 and the specified thread is the last thread executing in the process, or if ActionCode=1, the process terminates. DosExit allows a thread to terminate itself or be terminated by another thread in its process. If ActionCode=0 and the specified thread is the last thread executing in the process, or if ActionCode=1, the process terminates.
  
Line 26: Line 31:
 When a process is terminating, all but one thread is terminated and that thread executes routines whose addresses have been specified with DosExitList. After resources have been cleaned up by the exit list routines, this thread and all other resources owned by the process are released.  When a process is terminating, all but one thread is terminated and that thread executes routines whose addresses have been specified with DosExitList. After resources have been cleaned up by the exit list routines, this thread and all other resources owned by the process are released. 
  
-===Family API Considerations===+==== Family API Considerations ===
 Some options operate differently in the DOS mode than in the OS/2 mode. Therefore, the following restrictions apply to DosExit when coding for the DOS mode: Some options operate differently in the DOS mode than in the OS/2 mode. Therefore, the following restrictions apply to DosExit when coding for the DOS mode:
   * There is no thread support in DOS 3.3; therefore DosExit exits the currently executing program.   * There is no thread support in DOS 3.3; therefore DosExit exits the currently executing program.
   * If ActionCode = 0 this option is ignored. It is equivalent to an ActionCode = 1.    * If ActionCode = 0 this option is ignored. It is equivalent to an ActionCode = 1. 
  
-==Example Code== +===== Example Code ===== 
-===C Binding===+ 
 +==== C Binding ===
 +<code c>
  
   #define INCL_DOSPROCESS   #define INCL_DOSPROCESS
Line 40: Line 48:
   USHORT  ResultCode;    /* Result Code to save for DosCwait */   USHORT  ResultCode;    /* Result Code to save for DosCwait */
  
 +</code>
  
 In this example, the main routine starts up another program, simple.exe, and then expects a return code of 3 to be returned. Simple.exe sets the return code with DosExit. In this example, the main routine starts up another program, simple.exe, and then expects a return code of 3 to be returned. Simple.exe sets the return code with DosExit.
  
 +<code c>
   #define INCL_DOSPROCESS   #define INCL_DOSPROCESS
      
Line 65: Line 75:
         else         else
            printf("something is wrong...");            printf("something is wrong...");
-  +</code>  
 ----------------simple.exe------------------ ----------------simple.exe------------------
 +<code c>
   #define INCL_DOSPROCESS   #define INCL_DOSPROCESS
      
Line 78: Line 88:
              RETURN_CODE);          /* Result code */              RETURN_CODE);          /* Result code */
      }      }
 +</code>
  
 The following example shows how to suspend and resume execution of a thread within a process. The main thread creates Thread2 and allows it to begin executing. Thread2 iterates through a loop that prints a line and then sleeps, relinquishing its time slice to the main thread. After one iteration by Thread2, the main thread suspends Thread2 and then resumes it. Subsequently, Thread2 completes the remaining three iterations.  The following example shows how to suspend and resume execution of a thread within a process. The main thread creates Thread2 and allows it to begin executing. Thread2 iterates through a loop that prints a line and then sleeps, relinquishing its time slice to the main thread. After one iteration by Thread2, the main thread suspends Thread2 and then resumes it. Subsequently, Thread2 completes the remaining three iterations. 
 +<code c>
   #define INCL_DOSPROCESS   #define INCL_DOSPROCESS
   #include <os2.h>   #include <os2.h>
Line 143: Line 154:
     DosSleep(SLEEPLONG);                         /* Sleep interval */     DosSleep(SLEEPLONG);                         /* Sleep interval */
   }   }
 +</code>
  
- +==== MASM Binding ===
-===MASM Binding===+<code asm>
  
   EXTRN  DosExit:FAR   EXTRN  DosExit:FAR
Line 153: Line 165:
   PUSH   WORD    ResultCode    ;Result Code to save for DosCwait   PUSH   WORD    ResultCode    ;Result Code to save for DosCwait
   CALL   DosExit   CALL   DosExit
 +</code>
 +===== Note =====
  
-=== Note === 
  
 This text based on [[http://www.edm2.com/index.php/DosExit_(FAPI)]] This text based on [[http://www.edm2.com/index.php/DosExit_(FAPI)]]