Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:10:23+00:00 2026-06-01T01:10:23+00:00

in making a simple cgi server for a course. To do that in some

  • 0

in making a simple cgi server for a course. To do that in some point I have to make a fork/exec to launch the cgi handler, the problem is that the exec keep returning errno 14. I’ve tried the following code in a standalone version an it works with and without the absolute path.

Here’s the code:

static void _process_cgi(int fd, http_context_t* ctx)
{
    pid_t childProcess;
    int ret;
    char returnValue[1024];
    log(LOG, "calling cgi", &ctx->uri[1], 0);

    if((childProcess = fork()) != 0)
    {
        ///
        /// Set the CGI standard output to the socket.
        ///
        dup2(fd, STANDARD_OUTPUT);
            //ctx->uri = "/simple.cgi"

        execl("/home/dvd/nwebdir/simple.cgi",&ctx->uri[1]);
        sprintf(returnValue,"%d",errno);

        log(LOG, "exec returned ", returnValue, 0);
        return -1;
    }

    ret = waitpid(childProcess,NULL,0);
    sprintf(returnValue,"%d",ret);
    log(LOG, "cgi returned", returnValue, 0);
}

Here is the list of sys calls that the server passes before reaching my code (in order):
– chdir
– fork
– setpqrp
– fork
I don’t know if this is relevant or not, but in my test program I don’t have chdir nor setpqrp.

The test code is the following:

pid_t pid;

    if ((pid = fork()) != 0)
    {
        execl("simple.cgi","simple");
        //execl("/home/dvd/nwebdir/simple.cgi","simple");
        return 0;
    }
    printf("waiting\n");
    waitpid(pid, NULL, 0);
    printf("Parent exiting\n");

Note I’ve tried both execl and execlp in the server code.

You can find the basic server implementation (without CGI) in here, the only changes I made was in the web funcion:
http://www.ibm.com/developerworks/systems/library/es-nweb/index.html

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:10:25+00:00Added an answer on June 1, 2026 at 1:10 am
    execl("simple.cgi","simple", NULL);
    

    The null is needed because execl() is a varargs – function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a simple byte buffer that stores its data in a char
I'm making a simple search form in rails. In my search view I have
I am making simple one on server side & one on client side application
I'm making simple image editor by C# winform. I'm trouble with make zoom function.
I'm making simple game with very simple thread (1 sec delay) got problem with
Im making a simple app for some friends to use on there android phone
i am making simple autosuggestion (autocompleter) plugin with jQuery. Unfortunately i have to use
I am making simple ANSI C program, that simulates Unix shell. So I am
Making a simple program which will generate a multiple choice form. I have an
I am making simple application that will take hotel name and price of item,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.