passing pointers in a system call ?

Posted on 2005-05-01
Last Modified: 2010-04-15
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.

Question by:sanjay_thakur
    LVL 23

    Accepted Solution

    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)

    LVL 4

    Expert Comment

    tell clearly
    LVL 4

    Author Comment

    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
    (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?

    LVL 4

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now