× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi, my name is Oleg. I am writing RPGLE programm.
Actually, i have been trying to spawn proccesses and then chek their
status but i have problem.
ProcessID = spawn(.....);
PID = waitpid(PID:stat_loc:0);
I use waitpid(PID:stat_loc:0) function to chek status but it always
return stat_loc = *zero but PID = ProcessID.
My code is near below. If anybode could help me - it would be great!!!!

/EJECT
H DFTACTGRP(*NO)
***
D spawn PR extproc('spawn') like(pid_t)
D path * value options(*string)
D fd_count 10I 0 value
D fd_map 10I 0 dim(256) options(*varsize:*omit)
D inherit likeds(inheritance_t)
D argv * dim(4)
D options(*varsize)
D envp * dim(256) options(*varsize)

D waitpid PR extproc('waitpid') like(pid_t)
D pid like(pid_t) value
D stat_locp *
D options 10I 0 value
d stat_p s *

D chkStatus PR
D status 10i 0
d n
d n
d n

d ended s n
d failed s n
d stopped s n
D flagset_t S 10U 0 based(Template)
D pid_t S 10I 0 based(Template)
D sigset_t s 20U 0 based(Template)
D parms s 100A dim(4)
D PgmLib s 100A inz('ALIBDV1')
D PgmName s 100A inz('ChildProc')
D path s 200A varying
D inh ds likeds(inheritance_t)
D argv s * dim(4)
D envp s * dim(256)
D processID s like(pid_t)

D cpid s like(pid_t)
D stat_loc s *
D stat_val s 10I 0 based(PtrStat)
D PtrStat s *
D options s 10I 0
D childStatus s 10i 0

D inheritance_t DS based(Template)
D flags like(flagset_t)
D pgroup like(pid_t)
D sigmask like(sigset_t)
D sigdefault like(sigset_t)

/free

path = '/QSYS.LIB/' + %trim(PgmLib) + '.LIB/' +
%trim(PgmName) + '.PGM';

parms(1) = path + x'00';
parms(2) = 'XXXX';
parms(3) = '1080812';
parms(4) = '2';

argv(1) = %addr(parms(1));
argv(2) = %addr(parms(2));
argv(3) = %addr(parms(3));
argv(4) = %addr(parms(4));

inh = *ALLx'00';

processID = spawn(path: 0: *OMIT: inh: argv: envp);
if processID < 0;
// ReportError();
endif;
cpid = waitpid(processID:stat_loc:0);
select;
when ( cpid = ProcessID );
PtrStat = %Addr(stat_loc);
ChkStatus(stat_val:ended:failed:stopped);
when ( cpid = 0 );
//
when ( cpid = -1 );
//
endsl;

*inlr = *on;
/end-free

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.