• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

passing pointers in a system call ?

Hi,
I want to know how , if it is possible to pass pointers in a system call.

Basically, I  have command line utility functions in a executable say a.out.
from another executable b.out I invoke System calls in a.out.
But I would also like to pass pointers in the System call to be updated by this command line utility.

How do I do this?
a.out is not a running process, it is a command line utility that will exit once the system call is executed.

What are the other efficient solutions I can have for this scenario.
Can I use some perl help to pass pointers.

0
sanjay_thakur
Asked:
sanjay_thakur
  • 2
1 Solution
 
brettmjohnsonCommented:
Yes you can pass pointers to system calls.
It is not clear from your question what you are trying to do.
You cannot do this:

Process B passes a pointer in its address space to process A via some IPC.
Process A then passes that pointer to a system call.  The pointer is an
address in process B, but the system doesn't know that.  The system
only knows that the pointer is not a valid address in process A, from
which it received the pointer.  If process A acts as a proxy for process B,
then you must communicate the data appropriately.  Depending upon your
needs and the technology available, this is often done with something like:

 - shared memory (process A and B share a chunk of address space)
 - data/object serialization (the full data is passed from B to A)
 - formal remote object technology (CORBA, RMI, PDO, RPC, etc)



0
 
smpoojaryCommented:
tell clearly
0
 
sanjay_thakurAuthor Commented:
OK:
A attaches itself to shared memory: ptr
A invokes the system call : system(blah);

B attaches itself to shared memory
B executes the system call
Updates the pointer (ptr)
Detaches from shared memory
exits
(B is just a command line utility that will execute the system call and exit)

I presume this will work.
My question:
1) Is there any way to avoid having to use shared memory
2) How exactly do I pass ptr in system calls, curious?







0
 
smpoojaryCommented:
You can send ptr to other process. You can update the ptr in other process. But you can't access the value of that ptr pointing to in other process.

you can use file, FIFOs, messages, share memory, sockets.
-Mahesh
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now