5

Worker Program Help

view full story
linux-howto

http://www.linuxquestions.org – Here's what I'm trying to do: I'm attempting to create a Worker program which is to be called in a Coordinator program. The worker program needs to add two numbers from the argv and return the sum of those numbers. Basically my problem is some sort of syntax and I'm fairly new to this scripting stuff. Here's what I have: #!/bin/bash # Worker class for the program Coordinator int worker(int argc, char *argv[] { int sum = 0; sum = atoi(argv[1]) + atoi(argv[2]); printf("I am child with PID %d", getpid()); printf("sum=%d\n", sum); fprintf(atoi (argv[3]), sum, 4); exit(sum); } Here's the errors: ~$./worker 2 4 ./worker: line 4: syntax error near unexpected token `(' ./worker: line 4: `int worker(int argc, char *argv[]' (HowTos)