IPC Function Callback


#1

Hello,

I have two processes. One is running in a sandbox (Process1), the other is modifying files and so not running in a sandbox (Process2).

The Process2 has an API to call a function:

HANDLER LineHandler
(
string jsonString[MAX_JSON_LEN] IN ///< JsonString which is passed to the handler.
);

FUNCTION readLineWithHandler
(
FileSelector fileToWrite IN, ///< select file to read from.
handler LineHandler ///< handler which gets called after a new line is read.
);

The implemented readLineWithHandler-Function in Process2 looks more or less like this:

void fileHandler_readLineWithHandler(fileHandler_FileSelector_t fileselector, fileHandler_LineHandlerFunc_t handlerPtr, void* contextPtr)
{

//OPEN FILE

while( (read = getline(&line, &len, fp)) != -1 )
{
handlerPtr(line, NULL); //CALL PASSED FUNCTION FOR EVERY LINE WHICH IS READ.
}

//CLOSE FILE
}

The passed Function from Process1 has the following signature:

static void jsonParser(const char* line, void* contextPtr);

And i pass it from Process1 like this:

fileHandler_readLineWithHandler(FILEHANDLER_CONFIGFILE, &jsonParser, NULL);

But I am not able to get any callbacks. How could this be done?

Thanks!


#2

Is it even possible to do something like that with an sandboxed and an unsandboxed process? Because probably the allocated memory where the function is, is not valid to access in the second process.
So maybe I should go with events and everytime I would pass a new line to the handlerPtr, I would update the EVENT?

Thanks!