简体   繁体   中英

How much data can be passed as command line arguments?

在Linux下生成进程时,可以作为命令行参数发送多少字节?

Good article describes the issue:

http://www.in-ulm.de/~mascheck/various/argmax/

gahooa suggests a good article at http://www.in-ulm.de/~mascheck/various/argmax/ , but if that page disappears someday, here's the meat of the matter: to find the max length of your command line arguments try one of the following

* command: getconf ARG_MAX
* system call: sysconf(_SC_ARG_MAX)
* system header: ARG_MAX in e.g. <[sys/]limits.h>

This snippet will tell you.

#include <stdio.h>
#include <unistd.h>

int main(int argc, char** argv)
{
    const long value = sysconf(_SC_ARG_MAX);
    printf("ARG_MAX: %ld\n", value);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM