Re: "Run .. returning" & "exit program"
Posted in 1997
Michael Hoffman wrote: > > Hi all, > I stumbled upon a little problem that I'm hoping one of the gurus has > solved in the past. > > I am using Informix 4gl and calling another 4ge program ("run x.4ge > returning y"). The other program passes back an integer ("exit program(a)"). > > The problem: 'y' should equal 'a', correct? Well... it doesn't. > After looking at the data, I found that 'y' actually equals the second 8 bits > of 'a'. > [example: a = 6649 (binary = 00011001 11111001); > y = 63744 (binary = 11111001 00000000); ] > > How do I get around this problem? > > My system: Informix v. 5.04 on HP-UX 10.01 The 'returning' value from a 'run' statements is nothing more than the return value given to the operating system call exit(), therefore it should be a *byte*. The reason why it's shifted is to give room in case the underlying exec() 4GL is doing fails, and give back the reason of failure. Getting the significant byte is just a matter of doing an eight position bitwise right shift, which can be accomplished dividing by 256 :-) Of course, you should *not* return values outside the [0,255] range from the spawned process, or else will lose the high order bits. BTW, this will happen on *any* Unix platform. -- Ernesto Hern'ndez-Novich - emhn@telcel.net.ve Just another Unix/Perl/Java hacker. One thing is to be the best, and another is to be the most popular. Unix: Live free or die!