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 5981563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:57:41+00:00 2026-05-22T21:57:41+00:00

This function implements the API to change process title: http://lxr.evanmiller.org/http/source/os/unix/ngx_setproctitle.c 59 for (i =

  • 0

This function implements the API to change process title:

http://lxr.evanmiller.org/http/source/os/unix/ngx_setproctitle.c

59     for (i = 0; environ[i]; i++) {
 60         if (ngx_os_argv_last == environ[i]) {
 61 
 62             size = ngx_strlen(environ[i]) + 1;
 63             ngx_os_argv_last = environ[i] + size;
 64 
 65             ngx_cpystrn(p, (u_char *) environ[i], size);
 66             environ[i] = (char *) p;
 67             p += size;
 68         }
 69     }
 70 
 71     ngx_os_argv_last--;
 72 
 73     return NGX_OK;
 74 }

What I don’t understand is ,after copy the environment variables to block allocated by ngx_alloc(size, log);,how is that block connected with argv[] block?

I don’t see such logic there.

And there’s one line I don’t understand:

ngx_os_argv_last--;

What’s it for, is this line that connects the allocated block with argv[]?

  • 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-05-22T21:57:42+00:00Added an answer on May 22, 2026 at 9:57 pm

    The comment at the beginning of the module seems to explain a lot, have you read it?

    http://lxr.evanmiller.org/http/source/os/unix/ngx_setproctitle.c#L14

    It appears the ngx_init_setproctitle() function simply sets up the memory for setting the process title and does no real changes to the title. The comment at the beginning of the module states that it needs to setup the memory for setting the process title because argv[0] may not have the space for the new title (which is what needs to be set in order to change the title).

    The ngx_os_argv_last variable simply points to the end of the contiguous chunk for argv[] and environ[]. It’s used later in the copy process in ngx_setproctitle(). The last ngx_os_argv_last-- is probably to account for the '\0' at the end of the string.

    The ngx_init_setproctitle() create the space with ngx_alloc() then copies environ[] into the new space. The ngx_setproctitle() function simply copies over ngx_os_argv[0] with the new value title.

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

Sidebar

Related Questions

With this code function someFunction(classParam:Class):Boolean { // how to know if classParam implements some
<html> <head> <title></title> <script type=text/javascript src=http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true></script> <script src=Scripts/jquery-1.4.1.min.js type=text/javascript></script> <script type=text/javascript> $(function () {
What is the most elegant way to implement this function: ArrayList generatePrimes(int n) This
Since this function is implemented in IE8, I wanted to see exactly what I
This function appears to be a way to access all sorts of system values.
This function declaration gives me errors: ostream& operator<<(ostream& os, hand& obj); The errors are:
This function is written in ActionScirpt. What kind of decryption this is? Is there
This function of mine keeps on failing an autograder, I am trying to figure
Is this function declaration in C#: void foo(string mystring) the same as this one
Imagine this function: void SoundManager::playSource(ALuint sourceID, float offset) { alSourceStop(sourceID); ALint iTotal = 0;

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.