Search code examples
node.jslibuv

libuv: What is uv_setup_args function?


While reading node.js's source code, I came across this:

// Hack around with the argv pointer. Used for process.title = "blah".
argv = uv_setup_args(argc, argv);

I have not found any documentation on the function on libuv docs, as if it didn't even exist. I also checked if it was defined elsewhere in node.js code; it isn't.

Can anyone enlighten me on what it does? Also, could you point me to the documentation, if it exists?


Solution

  • It looks like it gets the arguments to the program (in this case, your node process):

    http://docs.libuv.org/en/v1.x/misc.html?highlight=uv_setup_args#c.uv_setup_args

    The syntax is extremely similar to many C programs that have a main function like:

    int main (int argc, char *argv[])
    

    The argc variable typically holds the argument count, while argv is the argument vector -- the actual string values passed in (on the command line, for example).