Re: system_exec()

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Fri, Jul 11, 2003 at 11:49:25PM +0200, Juergen Luethje wrote:
> 
> 
> Hi Jim, thanks for your reply.
> 
> > On Fri, Jul 11, 2003 at 07:15:38PM +0400, Igor Kachan wrote:
> > <snip>
> >>> Is the behaviour of system()/system_exec() the same on all windows
> >>> platforms? How about Linux/FreeBSD? I think this should be clearly
> >>> documented.
> >>
> >> Windows, Linux, FreeBSD are all multitasking OSs,
> >> so system() doesn't stop your parent program.
> >
> > Yes it does.
> >
> > In linux/freebsd, EU system() is a wrapper for C's system(), as is
> > system_exec().
> >
> > some pseudo code for thought:
> >
> > void eu_system(eu_sequence command, eu_integer wait)
> > {
> > 	system(make_char_array(command));
> > 	... here would be the ncurses code that figures out what do do with wait
> > }
> >
> > eu_integer eu_system_exec(eu_sequence command, eu_integer wait)
> > {
> > 	int ret = system(make_char_array(command));
> > 	... here would be the ncurses code that figures out what do do with wait
> > 	return make_eu_integer(ret);
> > }
> >
> > And, glibc/libc's system():
> >
> > int system(char* command)
> > {
> >            int pid, status;
> >
> >            if (command == 0)
> >                return 1;
> >            pid = fork();
> >            if (pid == -1)
> >                return -1;
> >            if (pid == 0) {
> >                char *argv[4];
> >                argv[0] = "sh";
> >                argv[1] = "-c";
> >                argv[2] = command;
> >                argv[3] = 0;
> >                execve("/bin/sh", argv, environ);
> >                exit(127);
> >            }
> >            do {
> >                if (waitpid(pid, &status, 0) == -1) {
> >                    if (errno != EINTR)
> >                        return -1;
> >                } else
> >                    return status;
> >            } while(1);
> > }
> >
> > ....in short, system() makes us wait in *nix too. (I did hook into glibc
> > so I could run a child process asychnronously ... but thats not something
> > provided by the language directly. At all.)
> 
> <snip>
> 
> 
> I'll try to summarize (S: run a child process  sychnronously,
>                        A: run a child process asychnronously):
> 
> 
>          |    Euphoria command
>          |
>          | system() | system_exec()
> ---------+----------+--------------
> DOS      |    S     |      S
> ---------+----------+--------------
> Windows  |    A     |      S
> ---------+----------+--------------
> Linux    |    S     |      S
> ---------+----------+--------------
> FreeBSD  |    S     |      S
> 
> 
> Is this the bottom line?

I thought that system() under Windows would be 'S' not 'A' ... but then again
I probably wouldn't know...

jbrown

> 
> Best regards,
>    Juergen
> 
> -- 
>  /"\  ASCII ribbon campain  |    |\      _,,,---,,_
>  \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
>   X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
>  / \  and unneeded MIME     |  '---''(_/--'  `-'\_)
> 
> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu