Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-10

FpWaitPid() multiplies status by 256

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anton Shepelev

Hello, all

Can anybody suggest why the function

   function FpWaitPid
   (     pid:     TPid;
     var Status:  cint;
         Options: cint
   ):             TPid;

may return the status multiplied by 256? If my child pro- cess terminates with Halt(1), the status is 256, if with Halt(2), the status is 512, etc. I am sorry to say that I observe it with an old version of FPC -- 2.6.4+dfsg-4, be- cause it is installed on the remote machine with Debian/GNU Linux 8 that I use over SSH. I have requested the maintain- er to upgrade FPC and, if or when he complies, I will test again.

Please, do not forward replies to my e-mail.
Marco van de Voort
to Anton Shepelev

In our previous episode, Anton Shepelev said:

may return the status multiplied by 256? If my child pro- cess terminates with Halt(1), the status is 256, if with Halt(2), the status is 512, etc.

Entirely normal. Status is an opague format in POSIX, and there are macros to pry them apart.

In Free Pascal those become inline functions, but the result is the same. Consult man pages or freepascal documentation:

https://www.freepascal.org/docs-html/rtl/baseunix/wexitstatus.html (note also the see also links which lists some of the other macros)

Anton Shepelev
to Marco van de Voort

Marco van de Voort to Anton Shepelev:

Show quoted text 6 lines
> may return the status multiplied by 256? If my child > process terminates with Halt(1), the status is 256, if > with Halt(2), the status is 512, etc. Entirely normal. Status is an opague format in POSIX, and there are macros to pry them apart.

Thank you.

Please, do not forward replies to my e-mail.