I executing a C executable using exec.Command and exec.Start(). My C executable is in the current directory and this is my code
cmd := exec.Command("./a.out")
// stdout,err := cmd.StderrPipe()
stderr,_ := cmd.StderrPipe()
err := cmd.Start()
if err != nil {
log.Fatal(err)
}
log.Printf("Waiting for command to finish...")
s,err := ioutil.ReadAll(stderr)
log.Printf(string(s))
err = cmd.Wait()
log.Printf("Command finished with error: %v", err)
When i run this code, this is the output i get
2014/12/10 07:49:39 Waiting for command to finish...
2014/12/10 07:49:39 Command finished with error: exit status 11
My C hello world program is
#include <stdio.h>
int main(){
printf("hello world");
}
The C code is compiled with gcc version 4.8.2 and executable is a.out.
The C executable a.out is a simple hello world program, i am getting the correct output, but i can't understand why exec.Wait() is exiting with status code 11 and not with 0.
The executable('a.out') is running normally when i run on a linux terminal without any faults or errors