This call allows a program to start another program in a session.
DosStartSession
StartData (PSTARTDATA) - input
length (USHORT)
A length of 30 bytes may be specified for OS/2 applications that want to use only the environment and inheritance features.
A length of 50 bytes may be selected for applications that want to use all the functions provided by DosStartSession. However, a length of 50 bytes is not allowed if the Session Manager detects that the Presentation Manager is not present.
Value
The calling program (parent session) may specify a child session as the target of DosSelectSession, DosSetSession, and DosStopSession, for related sessions. The SessID and ProcID parameters, and termq, are applicable only when related = 1 is specified.
Note also that for related sessions, although a parent session/child session relationship is established, a parent process/child process relationship is not established.
Value
Value
o
Note: The maximum value allowed for the combined length of pgmname and pgminputs is 1024 characters. For more information on pgmname and pgminputs, see "Program Name/Program Input Considerations:" in the Remarks section.
termq (PBYTE)
o
The process that originally issued the DosStartSession request, also issues DosReadQueue. Because this is the only process that has addressability to the notification data element, it is important that the NoWait parameter of DosReadQueue is set equal to zero. This process must also issue DosFreeSeg to free the segment containing the data element after it reads and processes the data element.
o
Value
Value
o
See "Program Handle Considerations:" in the Remarks section for more information.
Bit
Any error code returned from DosOpen, DosLoadModule, and DosExecPgm is also possible from DosStartSession.
Remarks
When a length of 24 bytes is specified, DosStartSession assumes the iconfile,
pgmhandle, sessiontype, pgmcontrol, initxpos, initypos, initxsize, and initysize
parameters to be 0. A value of 0 allows the Shell to establish the program
title, icon definition, session type, program control, window size, and
window position for the specified program.
Foreground/Background Considerations:
If fgbg = 0 is specified, and if neither the calling program nor any of
its descendant sessions is executing in the foreground, the new session
is started in the background. The ERROR_SMG_START_IN_BACKGROUND error code
is also returned in this case. The foreground session for windowed applications
is the session of the application that owns the window focus.
Parent/Child Relationships:
When related = 1 is specified, DosStartSession establishes a parent session/child
session relationship. A parent process/child process relationship is not
established. The parent process is the Shell process, just as if the operator
had started the program from the Shell menu. The ProcID returned by DosStartSession
may not be used by any OS/2 calls (for example, DosSetPrty)
that require a parent process/child process relationship. Once a process
has issued a DosStartSession, specifying related = 1, no other process within
that session may issue related DosStartSession calls until all the dependent
sessions have terminated.
Debugger Considerations:
Debuggers may want to debug all processes associated with an application, no matter how the process was started (DosExecPgm or DosStartSession). A special trace option, traceopt = 2, has been provided for this purpose. When traceopt = 2 is specified, the debugger must also supply the name of an existing queue as the termination queue name and related = 1 on the DosStartSession call.
The Session Manager notifies the debugger whenever a new session is created through DosStartSession from the initial session started with traceopt = 2 or from any descending session. The queue is posted regardless of how the new session is started: related, independent, with or without inheritance, and is executed for tracing. It is the responsibility of the debugger to resume the new process' execution through DosPtrace.
The debugger must issue DosReadQueue to receive notification when a child session is created. The word containing the request parameter returned by DosReadQueue is one. The data element structure returned has the following format:
Size
DosReadQueue, with the NoWait parameter set to zero, should be issued by the debugger. This is the only process that has addressability to the notification data element. After reading and processing the data element, the debugger must free the segment containing the data element using DosFreeSeg.
The debugger may use DosSelectSession to switch itself or any descendant session into the foreground whenever the current foreground session is a descendant of the debugger.
Some debuggers may enhance usability by using more than one display. Therefore, when a debugger registers with the Session Manager by using a traceopt of 2, the debugger is allowed to update the physical video buffer in the range of B000-B7FF, as long as the foreground session is a descendant of the debugger. The debugger is not allowed to update the physical video buffer when a session is switched into the foreground that is not a descendant of the debugger or when a popup occurs. Program Name/Program Input Considerations:
The program identified by pgmname is executed directly with no intermediate
secondary command
(CMD.EXE) process. Alternatively, the program can be executed indirectly
through a secondary command
(CMD.EXE) process by specifying CMD.EXE for pgmname and by specifying either
/C or /K followed by the drive, path, and file name of the application to
be loaded for pgminputs. If the /C parameter is inserted at the beginning
of the pgminputs string, the session terminates when the application program
terminates. If the /K parameter is inserted at the beginning of the pgminputs
string, the operator sees the OS/2 command line prompt displayed when the
application terminates. The operator can then either enter the name of
another program or command to execute or enter the OS/2 EXIT command to
terminate the session.
When the pgmname is accessed with a far address of 0 or the ASCIIZ string is null, the program specified as a parameter to the Shell in the PROTSHELL statement in the CONFIG.SYS file is executed and passed the specified pgminputs. This is the OS/2 mode command processor (CMD.EXE) by default.
When pgmname is equal to the command processor named on the PROTSHELL statement
in CONFIG.SYS, or when the pgmname = NULL and length = 24 or 30 bytes, either
the command processor named in CONFIG.SYS or the default CMD.EXE is started
within the same session as the caller of DosStartSession.
Program Handle Considerations:
If a process issues a DosStartSession specifying only the program handle,
it must change to the working directory before it issues the DosStartSession,
and start the new process inherited. If a process is started with inheritopt
= 0, that process must change to the correct directory.
Parent/Child Termination Considerations:
A parent session has only one termination queue. The parent creates the termination queue before it issues its first DosStartSession call specifying the name of the queue. An application can use the termination queue for another purpose by passing a unique request parameter through the DosWriteQueue/DosReadQueue interface. Request parameter values 0 through 99 are reserved for OS/2. Request parameter values greater than 99 are available for application use.
If a parent session specifies the termq parameter on more than one DosStartSession call, the parameter is ignored on subsequent calls. Once a parent establishes a termination queue, the queue is posted when any child session terminates. The queue is posted regardless of who terminates the child session (for example, child, parent, or operator) and whether the termination is normal or abnormal. The termq data element structure has the following format:
Size
When a child session terminates, the result code returned in the termq data element is the result code of the program specified by pgmname assuming either:
If the program is executed indirectly through a secondary command (CMD.EXE) process and the /K parameter is specified, the result code of the processed command is returned.
When a child session running in the foreground terminates, the parent session becomes the foreground session. When a parent session terminates, any child sessions it created with DosStartSession, specifying related = 1, are terminated. When an independent session, created specifying related = 0, running in the foreground terminates, the Shell chooses the next foreground session. Descendant Considerations:
A session started through DosStartSession may in turn issue DosStartSession. These rules apply:
o
You may use DosExecPgm to start a process that is of the same type as the starting process. Process types include Presentation Manager, text-windowed, and full-screen. You may not use DosExecPgm to start a process that is of a different type than the starting process.
You must use DosStartSession to start a new process from a process that is of a different type. For example, use DosStartSession to start a Presentation Manager process from a non-Presentation Manager process.