Re: system_exec()

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

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?

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu