1. system_exec() on Linux
- Posted by Julio C. Galaret Viera <galaret at adinet.com?uy> Oct 10, 2007
- 673 views
According docs: "If it is not possible to run the program, system_exec() will return -1." While that happens on Windows, on Linux does not return -1 when trying to run a program that does not exist. Euphoria v. 2.5/3.l.1 Regards
2. Re: system_exec() on Linux
- Posted by Robert Craig <rds at Ra?idEuphor?a.com> Oct 10, 2007
- 631 views
Julio C. Galaret Viera wrote: > According docs: "If it is not possible to run the program, system_exec() will > return -1." > > While that happens on Windows, on Linux does not return -1 when trying to run > a program that does not exist. > > Euphoria v. 2.5/3.l.1 I tried the system_exec() example on Linux. It didn't return a -1 error code, but did return a non-zero code (32512) which indicates an error. Is that what you got? Maybe I just need to change the documentation. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: system_exec() on Linux
- Posted by Julio C. Galaret Viera <galaret at ?dinet.co?.uy> Oct 10, 2007
- 647 views
Robert Craig wrote: > > Julio C. Galaret Viera wrote: > > According docs: "If it is not possible to run the program, system_exec() > > will > > return -1." > > > > While that happens on Windows, on Linux does not return -1 when trying to > > run > > a program that does not exist. > > > > Euphoria v. 2.5/3.l.1 > > I tried the system_exec() example on Linux. > It didn't return a -1 error code, but did > return a non-zero code (32512) which indicates an error. > Is that what you got? > Maybe I just need to change the documentation. > > Regards, > Rob Craig > Rapid Deployment Software > <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> Yes, I got that non-zero code but if successful also returns a non-zero code. Can I rely on 32512 as being always returned when failing to run? Regards
4. Re: system_exec() on Linux
- Posted by Bernie Ryan <xotron at bluefr?g?com> Oct 10, 2007
- 624 views
- Last edited Oct 11, 2007
Robert Craig wrote: > > Julio C. Galaret Viera wrote: > > According docs: "If it is not possible to run the program, system_exec() > > will > > return -1." > > > > While that happens on Windows, on Linux does not return -1 when trying to > > run > > a program that does not exist. > > > > Euphoria v. 2.5/3.l.1 > > I tried the system_exec() example on Linux. > It didn't return a -1 error code, but did > return a non-zero code (32512) which indicates an error. > Is that what you got? > Maybe I just need to change the documentation. > > Regards, > Rob Craig > Rapid Deployment Software > <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> man system says: The value returned is -1 on error if the fork fails; otherwise return the status of the command. The status returned depends on the type of job your executing. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
5. Re: system_exec() on Linux
- Posted by Derek Parnell <ddparnell at big?ond.c?m> Oct 10, 2007
- 628 views
- Last edited Oct 11, 2007
I think that the Linux return code is in the rightmost byte of the return value from the C system() call. sysret = system(pszCommand); result = ((sysret & 0xFF00) >> 8); -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
6. Re: system_exec() on Linux
- Posted by Jason Gade <jaygade at ?a?oo.com> Oct 10, 2007
- 647 views
- Last edited Oct 11, 2007
Derek Parnell wrote: > > I think that the Linux return code is in the rightmost byte of the return > value > from the C system() call. > > sysret = system(pszCommand); > result = ((sysret & 0xFF00) >> 8); > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell Hmm. Interestingly enough, 32512 in hex is #7F00. Wait, your expression would give the leftmost byte for result then shift it into the lower eight bits. You lose the rightmost byte. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
7. Re: system_exec() on Linux
- Posted by Jason Gade <jaygade at yahoo??om> Oct 10, 2007
- 645 views
- Last edited Oct 11, 2007
Looking at the man pages for system(3) and wait(2), though, Derek is right. you should still get back -1 for an error, but your actual eight-bit exit status is in the lower half of the word you get back. Heh. Learn something new every day. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
8. Re: system_exec() on Linux
- Posted by Robert Craig <rds at RapidEuph?ria.co?> Oct 11, 2007
- 657 views
Julio C. Galaret Viera wrote: > > Robert Craig wrote: > > > > Julio C. Galaret Viera wrote: > > > According docs: "If it is not possible to run the program, system_exec() > > > will > > > return -1." > > > > > > While that happens on Windows, on Linux does not return -1 when trying to > > > run > > > a program that does not exist. > > > > > > Euphoria v. 2.5/3.l.1 > > > > I tried the system_exec() example on Linux. > > It didn't return a -1 error code, but did > > return a non-zero code (32512) which indicates an error. > > Is that what you got? > > Maybe I just need to change the documentation. > > Yes, I got that non-zero code but if successful also returns a non-zero code. > Can I rely on 32512 as being always returned when failing to run? system_exec() is just returning to you what was returned to it, I think by the Linux shell. I don't know if you can rely on that particular number being returned across different versions of Linux. It might be safer if you were to use some other method to check if the program actually exists and ran successfully. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
9. Re: system_exec() on Linux
- Posted by Julio C. Galaret Viera <galaret at adin?t.com.u?> Oct 11, 2007
- 657 views
- Last edited Oct 12, 2007
Robert Craig wrote: > > system_exec() is just returning to you what was returned to it, > I think by the Linux shell. I don't know if you can rely on > that particular number being returned across different > versions of Linux. It might be safer if you were to use > some other method to check if the program actually exists > and ran successfully. > > Regards, > Rob Craig > Rapid Deployment Software > <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a> Thanks.