Starting processes

Hi all,

I got a Resource Manager (RM) that starts up new processes when it gets a
message to do so.

My trouble is as follows.
The first time a send a message to the RM to start up a new process the
thing works properly.
After that point if a new message is catched by the RM to start up antoher
process the thing fails.

The RM works forever if the messages catched do not start up a new process.

The function I’m using to start up a process is either
spawnl(P_NOWAITO,…) or
spawnl(P_NOWAIT,…)

The error message I got from a 2ond spawnl on is
memory fault (core dumped)


An important thing to point out is that the 1st process has already ended
when a new
message to start up another process is catched by the RM. So that, it’s not
that of I got
not enough available memory because of the 1st process is still running

So my question is, how can I start up processes indefinetly?
What am I forgetting to free memory after the 1st process has ended?

Cheers

JcD

\


He may look like an idiot and talk like an idiot but
don’t let that fool you. He really is an idiot.
(Groucho Marx)

Juan Carlos Diaz y Carballo
School of Computer Science, Room 331
University of St Andrews, North Haugh
St Andrews, Fife, KY16 9SS
SCOTLAND - U.K.

Tel: +44 (0) [1334] 463268
Fax: +44 (0) [1334] 463278
Email: jcd@dcs.st-andrews.ac.uk
URL : http://www.dcs.st-andrews.ac.uk/~jcd/

“juan carlos” <jcd@dcs.st-and.ac.uk> wrote in
news:a50ur7$57f$1@inn.qnx.com:

My trouble is as follows.
The first time a send a message to the RM to start up a new process
the thing works properly.
After that point if a new message is catched by the RM to start up
antoher process the thing fails.

The RM works forever if the messages catched do not start up a new
process.

The function I’m using to start up a process is either
spawnl(P_NOWAITO,…) or
spawnl(P_NOWAIT,…)

The error message I got from a 2ond spawnl on is
memory fault (core dumped)

Where are you storing the path, and arg0, arg1… etc each time you call
spawnl? How are you syncronizing the access if you share them between all
spawnl() calls? Did the resource manager core dump or the process you
spawned? Just as a sanity check, you are null termininating the arg[n]
list right?

\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Thanks Adam,

Well the problem is definetely in the RM. It does core dump.

I’ve written a simple C program with the same spawnl() call inserted several
times and it works as many times as I want.

The bit in my RM (called dispatcher) that interacts with the spawnl() is
shown below.

main ()
{
bla bla bla
}

int
io_write (resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *ocb)
{
bla
bla
bla

spawnl(P_NOWAITO, “/ive/bin/”, “j9”, “cingal.cingalet.runner.Runner”, CingaletName, NULL);

free(buffer); // Free read/write global buffer

fprintf(stdout,"\nDispatcher listening and waiting…\n");
}

As said the 1st run it works. After the 1st time, when the child process
has even ended (I’ve performed a ps to verify that effectively the j9 process
is not running!) if I pass the same message to the RM to run the same process again it fails.
Again as noted at the top this doesn’t happen if I run the j9 process from the trivial C program.

Any ideas?

Cheers.

JcD


“Adam Mallory” <amallory@qnx.com> wrote in message news:Xns91BC6A105A075amalloryqnxcom@209.226.137.4

“juan carlos” <> jcd@dcs.st-and.ac.uk> > wrote in
news:a50ur7$57f$> 1@inn.qnx.com> :

My trouble is as follows.
The first time a send a message to the RM to start up a new process
the thing works properly.
After that point if a new message is catched by the RM to start up
antoher process the thing fails.

The RM works forever if the messages catched do not start up a new
process.

The function I’m using to start up a process is either
spawnl(P_NOWAITO,…) or
spawnl(P_NOWAIT,…)

The error message I got from a 2ond spawnl on is
memory fault (core dumped)

Where are you storing the path, and arg0, arg1… etc each time you call
spawnl? How are you syncronizing the access if you share them between all
spawnl() calls? Did the resource manager core dump or the
process you
spawned? Just as a sanity check, you are null termininating the arg[n]
list right?

\

Cheers,
Adam

QNX Software Systems Ltd.
[ > amallory@qnx.com > ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net

juan carlos <jcd@dcs.st-and.ac.uk> wrote:

Thanks Adam,

Well the problem is definetely in the RM. It does core dump.

I’ve written a simple C program with the same spawnl() call inserted several
times and it works as many times as I want.

I’m not sure how this manages to work the first time…

The bit in my RM (called dispatcher) that interacts with the spawnl() is
shown below.

main ()
{
bla bla bla
}

int
io_write (resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *ocb)
{
bla
bla
bla

spawnl(P_NOWAITO, “/ive/bin/”, “j9”,
“cingal.cingalet.runner.Runner”, CingaletName, NULL);

This should be:
spawnl(P_NOWAITO, “/ive/bin/j9”, “j9”,
“cingal.cingalet.runner.Runner”, CingaletName, NULL);

Path should be the path to the executable. To quote from the docs:

The spawnl() function creates and executes a new child process,
named in path …

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Thanks David!

Oops!

But it’s as you have suggested, actually!
Otherwise, as you well say, it simply doesn’t not work!
I mean, the missing j9 in my previous post was one of those
things of the copy & paste process to put the stuff in here!
:slight_smile:) Sorry about that!

But as said, it runs but only 1 single time. If I want to run it again
I have to kill the RM and started again

Cheers

JcD

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:a540bb$i7t$1@nntp.qnx.com

juan carlos <> jcd@dcs.st-and.ac.uk> > wrote:
Thanks Adam,

Well the problem is definetely in the RM. It does core dump.

I’ve written a simple C program with the same spawnl() call inserted
several
times and it works as many times as I want.

I’m not sure how this manages to work the first time…

The bit in my RM (called dispatcher) that interacts with the spawnl() is
shown below.

main ()
{
bla bla bla
}

int
io_write (resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *ocb)


bla
bla
bla

spawnl(P_NOWAITO, “/ive/bin/”, “j9”,
“cingal.cingalet.runner.Runner”, CingaletName, NULL);


This should be:
spawnl(P_NOWAITO, “/ive/bin/j9”, “j9”,
“cingal.cingalet.runner.Runner”, CingaletName, NULL);

Path should be the path to the executable. To quote from the docs:

The spawnl() function creates and executes a new child process,
named in path …

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“juan carlos” <jcd@dcs.st-and.ac.uk> wrote in
news:a547pq$ghu$1@inn.qnx.com:

But as said, it runs but only 1 single time. If I want to run it again
I have to kill the RM and started again

Perhaps if you can reduce your RM down to a small test case, you could post
it and we can all take a look.

\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>