public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: execvp returns after exec.....
@ 1997-09-26 12:46 Khosla, Deepak
  0 siblings, 0 replies; 3+ messages in thread
From: Khosla, Deepak @ 1997-09-26 12:46 UTC (permalink / raw)
  To: 'Sergey Okhapkin'; +Cc: 'gnu-win32@cygnus.com'

Yes, I looked into it and spawn with a wait would do the trick. (It 
appears exec is some form of asynchronous spawn). However, I have one 
problem; spawn will only take 1K max size argument list and in some 
cases this is not enough. Any ideas on how to work around that?

Regards

Deepak Khosla
281-514-9234
DKhosla@compaq.com

-----Original Message-----
From:	Sergey Okhapkin [SMTP:sos@prospect.com.ru]
Sent:	Friday, September 26, 1997 1:24 PM
To:	Khosla, Deepak
Subject:	RE: execvp returns after exec.....

Khosla, Deepak wrote:
>
> mysleep.exe -s 10 will cause mysleep to wait 10 secs before printing 
a
> message out. What I observe is that as soon as the execvp is done,
> control returns to my DOS prompt and I can continue to run commands 
as
> if the process was done. 10 secs later I get a message from 
mysleep.
> The output is shown below (and I noticed that the PID of the execd
> process is different from the original process). Does anyone know 
why
> this happens and is there a way for me to change the behavior to 
where
> control does not return until mysleep is done?

Use spawn() instead of exec(). Pids differs because getpid in mingw
environment returns Win32 pid, and you have two _different_ win32
processes.

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: execvp returns after exec.....
@ 1997-09-29  7:07 Khosla, Deepak
  0 siblings, 0 replies; 3+ messages in thread
From: Khosla, Deepak @ 1997-09-29  7:07 UTC (permalink / raw)
  To: 'Sergey Okhapkin'; +Cc: 'gnu-win32@cygnus.com'

You are right; part of the problem was that I was using the Minimalist 
GNU 32 in some cases trying a test to see if I could do without 
cygwin. I guess not.

By the way, if I run tst2 (which execs to mysleep) and I hit a ^C to 
interrupt, I get a dump:

(c:\mingw32\projects\srcbin\mysleep.exe 1000) In cygwin_except_handler 
exc C0000
005 at 1001D0AB sp 240D7F4
(c:\mingw32\projects\srcbin\mysleep.exe 1000) Exception trapped!
(c:\mingw32\projects\srcbin\mysleep.exe 1000) exception C0000005 at 
1001D0AB
(c:\mingw32\projects\srcbin\mysleep.exe 1000) exception: ax 0 bx 0 cx 
64 dx 0
(c:\mingw32\projects\srcbin\mysleep.exe 1000) exception: si 10100 di 1 
bp 240D7F
8 sp 240D7F4
(c:\mingw32\projects\srcbin\mysleep.exe 1000) exception is: 
STATUS_ACCESS_VIOLAT
ION
(c:\mingw32\projects\srcbin\mysleep.exe 1000) Stack trace:
(c:\mingw32\projects\srcbin\mysleep.exe 1000) frame 0: sp = 0x240D628, 
pc = 0x10
005FAE
(c:\mingw32\projects\srcbin\mysleep.exe 1000) frame 1: sp = 0x240D644, 
pc = 0x77
F94512
(c:\mingw32\projects\srcbin\mysleep.exe 1000) frame 2: sp = 0x240D668, 
pc = 0x77
F88EEB

I don't get this when I run mysleep directly and interrupt it. Any 
ideas?

Regards

Deepak Khosla
281-514-9234
DKhosla@compaq.com

-----Original Message-----
From:	Sergey Okhapkin [SMTP:sos@prospect.com.ru]
Sent:	Monday, September 29, 1997 9:23 AM
To:	Khosla, Deepak
Subject:	RE: execvp returns after exec.....

Khosla, Deepak wrote:
> Sergey, That's what I would have expected, but since the PID of the 
> exec'd process is different, it appears both exec & spawn display 
the
> 'fork + exec' behavior. Exec does not replace the current process in 
> strict Unix terms since I get a new process ID!

Cygwin PID remains the same :-) No way in win32 to replace the process 
with a new image. Only new process can be created.

> Why do you think it? The limits for spawn are the same like for 
exec.
>
> I am basing my comments on the _exec* and spawn* function 'man' 
pages
> from Visual C++.

The limits are the same in cygwin.

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job.


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* execvp returns after exec.....
@ 1997-09-26  6:27 Khosla, Deepak
  0 siblings, 0 replies; 3+ messages in thread
From: Khosla, Deepak @ 1997-09-26  6:27 UTC (permalink / raw)
  To: 'gnu-win32@cygnus.com'

I have a small piece of test code:

/**********************************************************************  
******************************/
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <errno.h>

void main()
{
   char *args[4], prog[80];
   int ch;
   strcpy (prog, "c:\\mingw32\\projects\\srcbin\\mysleep.exe");
   ch = '7';
   printf( "\n\n" );

   args[0] = prog;
   args[1] = "-s";
   args[2] = "10";
   args[3] = NULL;

   fprintf(stderr, "- Prog is: %s; my pid is %d\n", prog, getpid() );
   fprintf (stderr, "- Sending args:\n1 %s\n2 %s\n3 %s\n4 %s\n", 
args[0], args[1], args[2], args[3]);
      execvp( prog, args );

   /* This point is reached only if exec fails. */
   printf( "\nProcess was not execed. %d\n", errno );
   perror ("Not execd:");
   exit( 0 );
}
/**********************************************************************  
******************************/

mysleep.exe -s 10 will cause mysleep to wait 10 secs before printing a 
message out. What I observe is that as soon as the execvp is done, 
control returns to my DOS prompt and I can continue to run commands as 
if the process was done. 10 secs later I get a message from mysleep. 
The output is shown below (and I noticed that the PID of the execd 
process is different from the original process). Does anyone know why 
this happens and is there a way for me to change the behavior to where 
control does not return until mysleep is done?

------------- Output -------------------------
C:\mingw32\projects\srcbin>tst2


- Prog is: c:\mingw32\projects\srcbin\mysleep.exe; my pid is 391
- Sending args:
1 c:\mingw32\projects\srcbin\mysleep.exe
2 -s
3 10
4 (null)

C:\mingw32\projects\srcbin>dir
 Volume in drive C has no label.
 Volume Serial Number is F079-7ADD

 Directory of C:\mingw32\projects\srcbin

09/26/97  08:20a        <DIR>          .
09/26/97  08:20a        <DIR>          ..
09/26/97  08:17a                 1,437 mysleep.c
09/26/97  08:18a                10,500 mysleep.exe
09/26/97  08:20a                   899 tst2.c
09/26/97  08:20a                10,507 tst2.exe
              13 File(s)         73,807 bytes
                            576,462,336 bytes free

C:\mingw32\projects\srcbin>>> mysleep: pid 260: done sleeping 10 secs

C:\mingw32\projects\srcbin>
---------------------------------- End output 
------------------------


Regards

Deepak Khosla
281-514-9234
DKhosla@compaq.com

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-09-29  7:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-26 12:46 execvp returns after exec Khosla, Deepak
  -- strict thread matches above, loose matches on Subject: below --
1997-09-29  7:07 Khosla, Deepak
1997-09-26  6:27 Khosla, Deepak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).