octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

More weirdness with fork() in octave 5.1.0


From: Dr. K. nick
Subject: More weirdness with fork() in octave 5.1.0
Date: Wed, 2 Oct 2019 14:43:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

cat wb_ftest.m
printf("start\n");
ftest();
printf("stop\n");

cat ftest.m
function ftest()
  [pid msg]=fork();
  if (pid > 0)
    disp("par start")
    pause(3);
    disp("par term")
  elseif (pid==0)
    disp("chl start")
    pause(1);
    disp("chl term")
  endif
endfunction

My procedure:

1. I start octave

ps -Af | grep octave  (checking process list before running wb_ftest.m)
nick     1807    1071  0 14:18 tty2     00:00:00 /usr/bin/octave --gui
nick     1808    1807 97 14:18 ?        00:00:10
/usr/lib/octave/5.1.0/exec/x86_64-pc-linux-gnu/octave-gui --gui
nick     1823    1487  0 14:18 pts/3    00:00:00 grep octave

2. I run wb_ftest.m from command line

>> wb_ftest
start
par start
chl start
chl term
stop
>> par term
stop
>>

ps -Af | grep octave (checking process list wb_ftest.m has finished)
nick     1807    1071  0 14:18 tty2     00:00:00 /usr/bin/octave --gui
nick     1808    1807  7 14:18 ?        00:00:16
/usr/lib/octave/5.1.0/exec/x86_64-pc-linux-gnu/octave-gui --gui
nick     1863    1808  0 14:21 ?        00:00:00
/usr/lib/octave/5.1.0/exec/x86_64-pc-linux-gnu/octave-gui --gui
nick     1871    1487  0 14:22 pts/3    00:00:00 grep octave

As it seems, last line in wb_ftest.m (printf("stop\n"); ) is being
executed twice although the 'pid==0'-part in ftest.m should have
finished (I'l like it to have finished) by this time. Is this intended
or a bug? What would be the proper way to correct for this behavior?

The process listings before and after running this script show, that a
new process is being fork()-ed correctly but it won't be terminated
(although the parent stays around longer than the child) properly. Even
after closing octave (clicking on x) the forked process stays around.

ps -Af | grep octave
nick     1917       1  0 14:24 ?        00:00:00
/usr/lib/octave/5.1.0/exec/x86_64-pc-linux-gnu/octave-gui --gui
nick     1981    1487  0 14:31 pts/3    00:00:00 grep octave

The system is Arch Linux 64 Bit.

Marcin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]