<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with CreateProcess in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973122#M24470</link>
    <description>continuation of code: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
            case (ERROR_PATH_NOT_FOUND) 
                write (6,*) "Error calling Ghostscript: bad path" 
                !CALL DlgExit( dlg_modeless ) 
                !CALL DlgUninit( dlg_modeless ) 
                RETURN 
 
            case DEFAULT 
                 write (6,50) lasterror 
50               format ('Error  calling Ghostscript: GetLastError=',I5,' CreateProcess') 
                !CALL DlgExit( dlg_modeless ) 
                !CALL DlgUninit( dlg_modeless ) 
                RETURN 
        end select 
    end if 
 
    !  close pipe handle - child's instance will be closed when terminates 
    res= CloseHandle(pi%hThread) 
    if (res.eq.0) then 
      istat=GetLastError() 
    endif 
    if  (bWait .NEQV. .FALSE.) then !  wait /Wtime wait flag specified? 
      !   object to wait for 
      dwResult = WaitForSingleObject(pi%hProcess, -1) !  timeout time 
      if (dwResult == -1) then 
        write (6,150) GetLastError() 
150     format ('Error handling Ghostscript exit:  GetLastError=',I5,' WaitForSingleObject') 
      end if 
    end if 
    res= CloseHandle(pi%hProcess) !  close process handle or it won't die 
    if (res.eq.0) then 
      istat=GetLastError() 
    endif 
&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Nov 2001 08:52:15 GMT</pubDate>
    <dc:creator>grtoro</dc:creator>
    <dc:date>2001-11-08T08:52:15Z</dc:date>
    <item>
      <title>Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973118#M24466</link>
      <description>My Quickwin program makes repeated calls to another program (which runs minimized) using CreateProcess.  I followed the "startp" sample in the samples directory.  I have noticed the following sequence of events:  &lt;BR /&gt;  &lt;BR /&gt;a)  During the second and later calls, CreateProcess returns a .false. value, although the called program has executed properly.  My program then calls GetLastError, which returns zero (i.e., ERROR_SUCCESS (great name!)).    &lt;BR /&gt;  &lt;BR /&gt;b) The call to CloseHandle(pi%hThread) returns 0 (error) and a call to GetLast Error returns 6 (ERROR_INVALID_HANDLE).    &lt;BR /&gt;  &lt;BR /&gt;c) The call to WaitForSingleObject(pi%hProcess, -1) returns -1 and and a call to GetLast Error also returns 6.    &lt;BR /&gt;  &lt;BR /&gt;d) The call to CloseHandle(pi%hProcess) returns 0 (error) and a call to GetLast Error also returns 6.   &lt;BR /&gt;  &lt;BR /&gt;In spite of this, the calling and called program seem to be working OK, although I suspect there may be a large memory leak (I have had to reboot once).  I have checked all non_null arguments to CreateProcess and nothing changes between the first and later calls.  In particular, dwCreate is 144, si is zero except for si%CB=68,  &lt;BR /&gt; si%DWFLAGS=1, si%WSHOWWINDOW=6, and pi is all zeros.  &lt;BR /&gt;  &lt;BR /&gt;Does anyone have any suggestion on how to correct this problem?   &lt;BR /&gt;  &lt;BR /&gt;Thanks,  &lt;BR /&gt;  &lt;BR /&gt;Gabriel</description>
      <pubDate>Thu, 08 Nov 2001 07:09:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973118#M24466</guid>
      <dc:creator>grtoro</dc:creator>
      <dc:date>2001-11-08T07:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973119#M24467</link>
      <description>Hmm, something is really fishy here. Could you post some relevant code please, especially CreateProcess part? (please enclose code in &lt;PRE&gt; ... &lt;/PRE&gt; HTML tags when posting so that it won't be screwed by Forum sogtware). Looks as if something &lt;B&gt;is&lt;/B&gt; different in second call to CreateProcess but I cannot figure out why. &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Thu, 08 Nov 2001 07:53:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973119#M24467</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-11-08T07:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973120#M24468</link>
      <description>&lt;PRE&gt; &lt;BR /&gt;  ! for createProcess &lt;BR /&gt; &lt;BR /&gt;  integer      res &lt;BR /&gt;  character    szArgs*512                       ! new process arguments buffer &amp;amp; temp pointer &lt;BR /&gt;  character                   DirName*512             ! current DirName for new process &lt;BR /&gt;  character                   szPgmName*(MAX_PATH)    ! name of the program &lt;BR /&gt;  logical(4)                  fSuccess                ! API return code &lt;BR /&gt;  type(T_STARTUPINFO)         si                      ! used for CreateProcess &lt;BR /&gt;  type(T_PROCESS_INFORMATION) pi                      ! used for CreateProcess &lt;BR /&gt;   &lt;BR /&gt;  logical(4)                  bMoreParams     ! flag end of new process parameter processing &lt;BR /&gt;  logical(4)                  bWait           ! wait/no wait for new process to end &lt;BR /&gt;  integer                     dwResult        ! API return code &lt;BR /&gt;  integer                     dwCreate        ! new process creation flags &lt;BR /&gt;  integer                     bExtension      ! input filename have an explicit extension? &lt;BR /&gt;  integer                     SIZEOFSTARTUPINFO &lt;BR /&gt;  integer                     SIZESECURITYATTRIBUTES &lt;BR /&gt; ! integer                     i &lt;BR /&gt;  character*5                 aExt(4) &lt;BR /&gt;  type(T_SECURITY_ATTRIBUTES) sa, sb &lt;BR /&gt;  data DirName /'0'/ &lt;BR /&gt;. &lt;BR /&gt;. &lt;BR /&gt;. &lt;BR /&gt; &lt;BR /&gt;! run gs using create process &lt;BR /&gt;  dwCreate = CREATE_NEW_CONSOLE &lt;BR /&gt;  dwCreate = IOR(HIGH_PRIORITY_CLASS,dwCreate)!  &lt;BR /&gt; &lt;BR /&gt;  SIZEOFSTARTUPINFO = 68 &lt;BR /&gt;  call ZeroMemory (LOC (si), SIZEOFSTARTUPINFO) &lt;BR /&gt;  si%cb= SIZEOFSTARTUPINFO &lt;BR /&gt;  !pi=T_PROCESS_INFORMATION(0,0,0,0)   ! 4 integer*4 quantities &lt;BR /&gt;  PI%hProcess =0  &lt;BR /&gt;  PI%hThread =0  &lt;BR /&gt;  PI%dwProcessId =0  &lt;BR /&gt;  PI%dwThreadId =0  &lt;BR /&gt;   &lt;BR /&gt; &lt;BR /&gt;  !minimized &lt;BR /&gt;   si%wShowWindow = SW_MINIMIZE &lt;BR /&gt;   si%dwFlags = IOR(STARTF_USESHOWWINDOW, si%dwFlags) &lt;BR /&gt;  !maximized &lt;BR /&gt; ! si%wShowWindow = SW_SHOWMAXIMIZED &lt;BR /&gt; ! si%dwFlags = IOR (STARTF_USESHOWWINDOW, si%dwFlags) &lt;BR /&gt; &lt;BR /&gt;  bWait=.true. &lt;BR /&gt; &lt;BR /&gt;  SIZESECURITYATTRIBUTES = 12 &lt;BR /&gt;  sa%nLength = SIZESECURITYATTRIBUTES &lt;BR /&gt;  sa%lpSecurityDescriptor = NULL &lt;BR /&gt;  sa%bInheritHandle = .true. &lt;BR /&gt; &lt;BR /&gt;!  IF ( .not. DlgInit( IDD_MAY_TAKE_TIME , dlg_modeless ) ) THEN &lt;BR /&gt;!    WRITE (6,*) "Error: dialog not found: IDD_MAY_TAKE_TIME" &lt;BR /&gt;!  ENDIF &lt;BR /&gt;!  istat = DlgModeless( dlg_modeless ) &lt;BR /&gt;   &lt;BR /&gt;  fSuccess=.true. &lt;BR /&gt; !note: GS_CMD and GS_LIB are always read from the same file and do not change  &lt;BR /&gt; fSuccess = CreateProcess( &amp;amp; &lt;BR /&gt;       TRIM(GS_CMD)//CHAR(0),    &amp;amp;                     ! image file name &lt;BR /&gt;       TRIM(GS_LIB)//' @tree_tmp.gs'//CHAR(0), &amp;amp;       ! command line (including program name) &lt;BR /&gt;                 NULL_security_attributes,      &amp;amp;  ! security for process &lt;BR /&gt;                 NULL_security_attributes,      &amp;amp;  ! security for main thread &lt;BR /&gt;                 .FALSE.,                       &amp;amp;  ! new process inherits handles? &lt;BR /&gt;                 dwCreate,                      &amp;amp;  ! creation flags &lt;BR /&gt;                 NULL,                          &amp;amp;  ! environment &lt;BR /&gt;                 null_character,                &amp;amp;  ! new current DirName &lt;BR /&gt;                 si,                            &amp;amp;  ! STARTUPINFO structure &lt;BR /&gt;                 pi)                               ! PROCESSINFORMATION structure &lt;BR /&gt; &lt;BR /&gt;    if (fSuccess .EQV. .FALSE.) then &lt;BR /&gt;        lasterror=GetLastError() &lt;BR /&gt;        select case (lasterror)              !  process common errors &lt;BR /&gt;            case ( ERROR_SUCCESS )  ! great name! &lt;BR /&gt;                continue &lt;BR /&gt;          
      WRITE(6,*)'fsuccess was false but GetlastError returns 0' &lt;BR /&gt;            case (ERROR_FILE_NOT_FOUND) &lt;BR /&gt;                write (6,*) "Error: Ghostscript program not found" &lt;BR /&gt;                !CALL DlgExit( dlg_modeless ) &lt;BR /&gt;                !CALL DlgUninit( dlg_modeless ) &lt;BR /&gt;                RETURN &lt;BR /&gt;            case (ERROR_DIRECTORY) &lt;BR /&gt;                write (6,*)("Error calling Ghostscript: bad starting directory") &lt;BR /&gt;                !CALL DlgExit( dlg_modeless ) &lt;BR /&gt;                !CALL DlgUninit( dlg_modeless ) &lt;BR /&gt;                RETURN &lt;BR /&gt;            case (ERROR_PATH_NOT_F&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2001 08:15:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973120#M24468</guid>
      <dc:creator>grtoro</dc:creator>
      <dc:date>2001-11-08T08:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973121#M24469</link>
      <description>&lt;PRE&gt; &lt;BR /&gt;  ! for createProcess &lt;BR /&gt; &lt;BR /&gt;  integer      res &lt;BR /&gt;  character    szArgs*512                       ! new process arguments buffer &amp;amp; temp pointer &lt;BR /&gt;  character                   DirName*512             ! current DirName for new process &lt;BR /&gt;  character                   szPgmName*(MAX_PATH)    ! name of the program &lt;BR /&gt;  logical(4)                  fSuccess                ! API return code &lt;BR /&gt;  type(T_STARTUPINFO)         si                      ! used for CreateProcess &lt;BR /&gt;  type(T_PROCESS_INFORMATION) pi                      ! used for CreateProcess &lt;BR /&gt;   &lt;BR /&gt;  logical(4)                  bMoreParams     ! flag end of new process parameter processing &lt;BR /&gt;  logical(4)                  bWait           ! wait/no wait for new process to end &lt;BR /&gt;  integer                     dwResult        ! API return code &lt;BR /&gt;  integer                     dwCreate        ! new process creation flags &lt;BR /&gt;  integer                     bExtension      ! input filename have an explicit extension? &lt;BR /&gt;  integer                     SIZEOFSTARTUPINFO &lt;BR /&gt;  integer                     SIZESECURITYATTRIBUTES &lt;BR /&gt; ! integer                     i &lt;BR /&gt;  character*5                 aExt(4) &lt;BR /&gt;  type(T_SECURITY_ATTRIBUTES) sa, sb &lt;BR /&gt;  data DirName /'0'/ &lt;BR /&gt;. &lt;BR /&gt;. &lt;BR /&gt;. &lt;BR /&gt; &lt;BR /&gt;! run gs using create process &lt;BR /&gt;  dwCreate = CREATE_NEW_CONSOLE &lt;BR /&gt;  dwCreate = IOR(HIGH_PRIORITY_CLASS,dwCreate)!  &lt;BR /&gt; &lt;BR /&gt;  SIZEOFSTARTUPINFO = 68 &lt;BR /&gt;  call ZeroMemory (LOC (si), SIZEOFSTARTUPINFO) &lt;BR /&gt;  si%cb= SIZEOFSTARTUPINFO &lt;BR /&gt;  !pi=T_PROCESS_INFORMATION(0,0,0,0)   ! 4 integer*4 quantities &lt;BR /&gt;  PI%hProcess =0  &lt;BR /&gt;  PI%hThread =0  &lt;BR /&gt;  PI%dwProcessId =0  &lt;BR /&gt;  PI%dwThreadId =0  &lt;BR /&gt;   &lt;BR /&gt; &lt;BR /&gt;  !minimized &lt;BR /&gt;   si%wShowWindow = SW_MINIMIZE &lt;BR /&gt;   si%dwFlags = IOR(STARTF_USESHOWWINDOW, si%dwFlags) &lt;BR /&gt;  !maximized &lt;BR /&gt; ! si%wShowWindow = SW_SHOWMAXIMIZED &lt;BR /&gt; ! si%dwFlags = IOR (STARTF_USESHOWWINDOW, si%dwFlags) &lt;BR /&gt; &lt;BR /&gt;  bWait=.true. &lt;BR /&gt; &lt;BR /&gt;  SIZESECURITYATTRIBUTES = 12 &lt;BR /&gt;  sa%nLength = SIZESECURITYATTRIBUTES &lt;BR /&gt;  sa%lpSecurityDescriptor = NULL &lt;BR /&gt;  sa%bInheritHandle = .true. &lt;BR /&gt; &lt;BR /&gt;!  IF ( .not. DlgInit( IDD_MAY_TAKE_TIME , dlg_modeless ) ) THEN &lt;BR /&gt;!    WRITE (6,*) "Error: dialog not found: IDD_MAY_TAKE_TIME" &lt;BR /&gt;!  ENDIF &lt;BR /&gt;!  istat = DlgModeless( dlg_modeless ) &lt;BR /&gt;   &lt;BR /&gt;  fSuccess=.true. &lt;BR /&gt; !note: GS_CMD and GS_LIB are always read from the same file and do not change  &lt;BR /&gt; fSuccess = CreateProcess( &amp;amp; &lt;BR /&gt;       TRIM(GS_CMD)//CHAR(0),    &amp;amp;                     ! image file name &lt;BR /&gt;       TRIM(GS_LIB)//' @tree_tmp.gs'//CHAR(0), &amp;amp;       ! command line (including program name) &lt;BR /&gt;                 NULL_security_attributes,      &amp;amp;  ! security for process &lt;BR /&gt;                 NULL_security_attributes,      &amp;amp;  ! security for main thread &lt;BR /&gt;                 .FALSE.,                       &amp;amp;  ! new process inherits handles? &lt;BR /&gt;                 dwCreate,                      &amp;amp;  ! creation flags &lt;BR /&gt;                 NULL,                          &amp;amp;  ! environment &lt;BR /&gt;                 null_character,                &amp;amp;  ! new current DirName &lt;BR /&gt;                 si,                            &amp;amp;  ! STARTUPINFO structure &lt;BR /&gt;                 pi)                               ! PROCESSINFORMATION structure &lt;BR /&gt; &lt;BR /&gt;    if (fSuccess .EQV. .FALSE.) then &lt;BR /&gt;        lasterror=GetLastError() &lt;BR /&gt;        select case (lasterror)              !  process common errors &lt;BR /&gt;            case ( ERROR_SUCCESS )  ! great name! &lt;BR /&gt;                continue &lt;BR /&gt;          
      WRITE(6,*)'fsuccess was false but GetlastError returns 0' &lt;BR /&gt;            case (ERROR_FILE_NOT_FOUND) &lt;BR /&gt;                write (6,*) "Error: Ghostscript program not found" &lt;BR /&gt;                !CALL DlgExit( dlg_modeless ) &lt;BR /&gt;                !CALL DlgUninit( dlg_modeless ) &lt;BR /&gt;                RETURN &lt;BR /&gt;            case (ERROR_DIRECTORY) &lt;BR /&gt;                write (6,*)("Error calling Ghostscript: bad starting directory") &lt;BR /&gt;                !CALL DlgExit( dlg_modeless ) &lt;BR /&gt;                !CALL DlgUninit( dlg_modeless ) &lt;BR /&gt;                RETURN &lt;BR /&gt;            case (ERROR_PATH_NOT_F&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2001 08:35:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973121#M24469</guid>
      <dc:creator>grtoro</dc:creator>
      <dc:date>2001-11-08T08:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973122#M24470</link>
      <description>continuation of code: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
            case (ERROR_PATH_NOT_FOUND) 
                write (6,*) "Error calling Ghostscript: bad path" 
                !CALL DlgExit( dlg_modeless ) 
                !CALL DlgUninit( dlg_modeless ) 
                RETURN 
 
            case DEFAULT 
                 write (6,50) lasterror 
50               format ('Error  calling Ghostscript: GetLastError=',I5,' CreateProcess') 
                !CALL DlgExit( dlg_modeless ) 
                !CALL DlgUninit( dlg_modeless ) 
                RETURN 
        end select 
    end if 
 
    !  close pipe handle - child's instance will be closed when terminates 
    res= CloseHandle(pi%hThread) 
    if (res.eq.0) then 
      istat=GetLastError() 
    endif 
    if  (bWait .NEQV. .FALSE.) then !  wait /Wtime wait flag specified? 
      !   object to wait for 
      dwResult = WaitForSingleObject(pi%hProcess, -1) !  timeout time 
      if (dwResult == -1) then 
        write (6,150) GetLastError() 
150     format ('Error handling Ghostscript exit:  GetLastError=',I5,' WaitForSingleObject') 
      end if 
    end if 
    res= CloseHandle(pi%hProcess) !  close process handle or it won't die 
    if (res.eq.0) then 
      istat=GetLastError() 
    endif 
&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2001 08:52:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973122#M24470</guid>
      <dc:creator>grtoro</dc:creator>
      <dc:date>2001-11-08T08:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973123#M24471</link>
      <description>I've pasted your code with minor changes (actually, I invoked cmd instead of GhostScript because I was lazy to investigate gs command line options and added an infinite loop instead of turning it into a subroutine) -- and it worked beautifully ;-). Btw, is it Win9x or NT/2000? &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Thu, 08 Nov 2001 19:03:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973123#M24471</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-11-08T19:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with CreateProcess</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973124#M24472</link>
      <description>Jugoslav, &lt;BR /&gt; &lt;BR /&gt;Thanks for your help.  I am using W98 SE.  Two things I want to add: &lt;BR /&gt; &lt;BR /&gt;a)  The Ghostscript program works fine every time, even when I get the (apparently spurious) error messages.  I am mainly concerned with memory leaks that may be occuring.   &lt;BR /&gt; &lt;BR /&gt;b)  After seemingly harmless changes to dirName and other variables from "startp" that appear to be unused, I am finding that the errors occur only occasionaly (not consistently) after the first time. &lt;BR /&gt; &lt;BR /&gt;This is probably a problem my program can live with, but I would like to resolve it, especially because of the possibility of memory leaks. &lt;BR /&gt; &lt;BR /&gt;Thanks again, &lt;BR /&gt; &lt;BR /&gt;Gabriel</description>
      <pubDate>Thu, 08 Nov 2001 22:43:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-with-CreateProcess/m-p/973124#M24472</guid>
      <dc:creator>grtoro</dc:creator>
      <dc:date>2001-11-08T22:43:24Z</dc:date>
    </item>
  </channel>
</rss>

