cmichael@qucis.queensu.CA (Ian Carmichael) (02/05/90)
Does Execute always return -1? In the following code, caller always prints "Success = -1", regardless of the value of N in callee.c, or even if callee does not exist. Why? What is "the right way" to get the return code from Execute? caller.c -------- main() { int success; success = Execute ("callee",0,0); printf("Success = %d\n",success); } callee.c -------- #define N 0 main() { printf("Callee Exiting with return code %d\n",N); exit(N); } Thanks in advance, Ian Carmichael
wfh58@leah.Albany.Edu (William F. Hammond) (02/07/90)
In article <541@qusunb.queensu.CA>, cmichael@qucis.queensu.CA (Ian Carmichael) writes: > Does Execute always return -1? In the following code, caller always > prints "Success = -1", regardless of the value of N in callee.c, or even > caller.c > . . . > int success; > success = Execute ("callee",0,0); ^^^^^^ The first argument to Execute() is the filename of an executable in your command path. In this code "callee" is a function name inside the code. BTW, just for saftety, I would have been happier to see "0L" in the second and third arguments. (I don't know what your compiling environment is.) And, just for safety, if my memory is in gear this morning, Execute() returns "short". > . . . > callee.c > #define N 0 > main() > . . . ------------------------------------------------------------------------ William F. Hammond Dept. of Mathematics & Statistics 518-442-4625 SUNYA, Albany, NY 12222 wfh58@leah.albany.edu wfh58@albnyvms.bitnet -------------------------------------------------------------------------
koren@hpfelg.HP.COM (Steve Koren) (02/09/90)
> > success = Execute ("callee",0,0); ^^^^^^ > The first argument to Execute() is the filename of an executable in your > command path. In this code "callee" is a function name inside the code. I think Ian mant that "callee" was compiled ito a separate executable in the path. In any case, I think that the reason Execute() doesn't return the proper value is that it's busted. There are a few other problems with Execute() as well. Arp's SyncRun() command seems to work just fine, though,so you can use that until Excute() is fixed (in 1.4? please??) - steve
peter@sugar.hackercorp.com (Peter da Silva) (02/12/90)
In article <13920044@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes: > Arp's SyncRun() command > seems to work just fine, though,so you can use that until Excute() > is fixed (in 1.4? please??) Please don't *require* ARP, in any program. It just takes up precious disk space. I know the argument i sthat the smaller executables make the difference, but every time I've tried it I've had to dump enough Arp executables because they're not compatible with AmigaDOS executables that I ended up back on the minus side. -- _--_|\ Peter da Silva <peter@sugar.hackercorp.com>. / \ \_.--._/ I haven't lost my mind, it's backed up on tape somewhere! v "Have you hugged your wolf today?" `-_-'
cmcmanis@stpeter.Sun.COM (Chuck McManis) (02/13/90)
In response to the question of why Execute always returns -1 (Steve Koren) writes: >I think Ian mant that "callee" was compiled ito a separate >executable in the path. In any case, I think that the reason Execute() >doesn't return the proper value is that it's busted. The correct answer is that Execute thinks it is returning the correct value. If you read the original DOS technical reference manual you will see the quote : "Execute() returns TRUE if the program that was passed was EXECUTED." It doesn't say anything about return values of the executed function because it doesn't care about that. The original TriPOS OS assumed that the function you were executing would take care of getting it's result status to you by some "other" means. Of course most of us from UNIX or similar backgrounds think that we should be able to combine these two results. I believe this is the case in 1.4. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@Eng.Sun.COM These opinions are my own and no one elses, but you knew that didn't you. "If it didn't have bones in it, it wouldn't be crunchy now would it?!"
walker@sas.UUCP (Doug Walker) (02/13/90)
In article <541@qusunb.queensu.CA> cmichael@qucis.queensu.CA (Ian Carmichael) writes: >Does Execute always return -1? In the following code, caller always >prints "Success = -1", regardless of the value of N in callee.c, or even >if callee does not exist. Why? What is "the right way" to get the >return code from Execute? You ARE getting the return code from Execute. What you WANT is the return code from the program you executed. The -1 is saying 'yep, I launched the process for you successfully.' (-1 being DOS_TRUE, 0xffffffff). Anybody know how to get the return code of the program you Execute()ed? ***** =*|_o_o|\\=====Doug Walker, Software Distiller======================= *|. o.| || | o |// "I try to make everyone's day a little more surreal." ====== - Calvin usenet: ...mcnc!rti!sas!walker plink: dwalker bix: djwalker
koren@hpfelg.HP.COM (Steve Koren) (02/13/90)
> Please don't *require* ARP, in any program. It just takes up precious disk > space. I know the argument i sthat the smaller executables make the difference > but every time I've tried it I've had to dump enough Arp executables because > they're not compatible with AmigaDOS executables that I ended up back on the > minus side. One option (the one I picked) is to 1) install the arp.library, and 2) use the original AmigaDos commands (which I don't use much anyhow) for compatibility. If there is any truth to the rumor that Commodore will be shipping arp.library, it will become a moot point anyhow. Back when I had a floppy only system, I moved a few things like notepad and the clock off my boot disk to make room for arp.library. - steve
riley@batcomputer.tn.cornell.edu (Daniel S. Riley) (02/14/90)
In article <131688@sun.Eng.Sun.COM> cmcmanis@sun.UUCP (Chuck McManis) writes: >"Execute() returns TRUE if the program that was passed was EXECUTED." > >It doesn't say anything about return values of the executed function >because it doesn't care about that. Starting with 1.2, I believe IoErr() will return pr_Result2 from the program that was executed (pr_Result2 returns the AmigaDOS error code, like 214 == "disk write-protected"). This is not the same as the return code from the program, so "exit(25)" in a C program will show up as a 0 return value from IoErr()--you have to explicitly set pr_Result2 to a value to use this from C. If you are running WShell with Bill Hawes' patches to Execute(), then you get more useful information, but that's obviously non-standard. (This is based on a vague recollection of something Andy Finkel said on BIX long ago and far away. I'd check it, but I have Bill Hawes' patch installed...) -Dan Riley (riley@tcgould.tn.cornell.edu, cornell!batcomputer!riley) -Wilson Lab, Cornell University