How to spawn C code using exec

Hello,
I am having trouble launching a C program in spawn mode using an exec node.

I created a simplified example where a button starts the exec node. Unfortunately when I run it, I always get an error with return code of -2.

I have this little example committed here: GitHub - hdlguy/node-red_experiments

The C code is just a loop that generates some text output and then returns 0.

#include <stdio.h>
#include <unistd.h>
int main()
{
    for(int i=0; i<=100; i+=20) {
        fprintf(stdout, "%d\n", i);
        fflush(stdout);
        usleep(500000);
    }    
    return(0);
}

Add debug nodes to all outputs of the exec node, set them to Output Complete Message and check all properties of the outputs. There will probably be a helpful error message there.

Have you specified the full path to the executable file?

I don't see the flow in your repository.

You've not checked in the flow file so we have no idea how you've configured the exec node.

Also you probably want to swap the dashboard start button for a inject node to get started and set the debug node to whole message not just payload to see more.

You should also check the Node-RED logs for more error messages.

As it is there isn't really anything we can help with so far.

And I assume you have tested running the compiles c program from the command line first?

The code when complied and run with a full path works just fine on my Ubuntu box with NR 4.1.0

Please don't be offended by the question, but your exec node is trying to run the compiled executable, not the C source code? Edit: I think that would give rc -13

Does it make a difference if you specify the full pathname of the executable eg /home/pedro/.node-red/bin/gen_percent (or wherever the file is)?
One cause of rc -2 is that the OS cannot find the file to execute it.