I have the following backend functions:
// foo.c
void cStart(pid_t* pid)
{
*pid = getpid();
// event-loop keep running until receive SIGINT signal
}
void cStop(pid_t* pid)
{
kill(*pid, SIGINT);
}
// addon.cpp
#include "addon.h"
#include "foo.h"
Napi::Number addon::run_pipeline_wrapped(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
// get the buffer from JS, pass it to cStart to be modified in-place [?]
cStart(pid_t* pid);
}
Napi::Number addon::kill_pipeline_wrapped(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
// get the modified (by cStart) buffer from JS, pass it to cStop [?]
cStop(pid_t* pid);
}
From the front-end, when the start button is clicked, a C process will start running until it receive a SIGINT signal and when the stop button is clicked, SIGINT signal is sent to the running C process. int* will travel as follow: JS (start button clicked) -> C/C++ (cStart modified int* in place so int* is not explicitly returned to JS) -> JS (stop button clicked) -> C/C++). So how do I pass an int pointer back and forth between JS and C/C++?