kiss9815 / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Unexpected termination on popen use in embedded function, in mac #219

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This code as a user callback causes the main process to terminate. No errors 
happen, not in the popen and pclose calls nor in the process termination. And 
this code works on Linux! I haven't tested it on Windows yet.

static void embed_func(struct mg_connection *conn,
                    const struct mg_request_info *ri) {
    mg_printf(conn, "%s", standard_reply);

    FILE * fpipe = popen("pwd", "r");
    if (fpipe == NULL) {
        mg_printf(conn, "error");
        return;
    }
    char line[256];
    while (fgets(line, sizeof line, fpipe) != NULL) {
        mg_printf(conn, "%s", line);
    }
    int pclose_err = pclose(fpipe);
}

Original issue reported on code.google.com by remohamm...@gmail.com on 13 Jan 2011 at 10:06

GoogleCodeExporter commented 9 years ago
What is the OS and mongoose version?

Original comment by valenok on 20 Jan 2011 at 3:51

GoogleCodeExporter commented 9 years ago
What is the OS and mongoose version?

Original comment by valenok on 20 Jan 2011 at 3:51

GoogleCodeExporter commented 9 years ago
Mac OS X 10.6.6
mongoose 2.11
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646) (dot 1)

The same code works (without the termination :D) on Ubuntu 10.4.

Original comment by remohamm...@gmail.com on 20 Jan 2011 at 4:45

GoogleCodeExporter commented 9 years ago
This code works just fine on my Mac.
Could you try the HEAD version please?

Original comment by valenok on 21 Jun 2011 at 11:57