473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Max Size of argv[1] ???

consider :
int main (int argc, char * argv [ ]) {

}

In exec (2) ; Whose arguments which are passed to main.

What is the maximum size of the string.
argv[1] = "hello........." ;

How long can argv[1] point to. even though i know argv[i] is 4 bytes
pointer. How long can the string be ?.

I just want to send a 50K string as my process arguments (main's
args)
when i fork and exec.

Is it possible ?. Does standard say something on this ?.

Are there any limitations ?.
Regards,
James
Nov 14 '05 #1
13 8171
James <ja***********@yahoo.co.uk> wrote:
consider :
int main (int argc, char * argv [ ]) { } In exec (2) ; Whose arguments which are passed to main. What is the maximum size of the string.
argv[1] = "hello........." ; How long can argv[1] point to. even though i know argv[i] is 4 bytes
pointer. How long can the string be ?. I just want to send a 50K string as my process arguments (main's
args)
when i fork and exec. Is it possible ?. Does standard say something on this ?. Are there any limitations ?.


As far as I can tell, there's no requirement for the size of it in
the C standard (and I can't see any good reason why the standard
should require an upper limit). On the other hand, the operating
system will probably put a limit on the maximum size. E.g. the
POSIX standard SUSv3 requires that argv can use at least 4096 bytes
(but many Unices allow a lot more).

Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #2
Use a temp file and send the filename.
Remember both side should close the file since the File handle is reference
counted

"James" <ja***********@yahoo.co.uk> ???
news:2f**************************@posting.google.c om ???...
consider :
int main (int argc, char * argv [ ]) {

}

In exec (2) ; Whose arguments which are passed to main.

What is the maximum size of the string.
argv[1] = "hello........." ;

How long can argv[1] point to. even though i know argv[i] is 4 bytes
pointer. How long can the string be ?.

I just want to send a 50K string as my process arguments (main's
args)
when i fork and exec.

Is it possible ?. Does standard say something on this ?.

Are there any limitations ?.
Regards,
James

--
~ Samba, more than a low cost File and Printer server ~

-- Let us OpenSource --
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 14 '05 #3
Je***********@physik.fu-berlin.de wrote in message news:<2p************@uni-berlin.de>...
James <ja***********@yahoo.co.uk> wrote:
consider :
int main (int argc, char * argv [ ]) {

}

In exec (2) ; Whose arguments which are passed to main.

What is the maximum size of the string.
argv[1] = "hello........." ;

How long can argv[1] point to. even though i know argv[i] is 4 bytes
pointer. How long can the string be ?.

I just want to send a 50K string as my process arguments (main's
args)
when i fork and exec.

Is it possible ?. Does standard say something on this ?.

Are there any limitations ?.


As far as I can tell, there's no requirement for the size of it in
the C standard (and I can't see any good reason why the standard
should require an upper limit). On the other hand, the operating
system will probably put a limit on the maximum size. E.g. the
POSIX standard SUSv3 requires that argv can use at least 4096 bytes
(but many Unices allow a lot more).

Regards, Jens


There isn't a limit on the length of an individual argument, only on
the length of the entire argument line has the ARG_MAX limit imposed
on it, defined in limits.h. The following makes an interesting
comparison on the size of ARG_MAX across various systems:

http://rhols66.adsl.netsonic.fi/era/unix/arg-max.html

Regards,
Mark.
Nov 14 '05 #4
James wrote:
consider :
int main (int argc, char * argv [ ]) {

}

In exec (2) ; Whose arguments which are passed to main.

What is the maximum size of the string.
argv[1] = "hello........." ;

How long can argv[1] point to. even though i know argv[i] is 4 bytes
pointer. How long can the string be ?.

I just want to send a 50K string as my process arguments (main's
args)
when i fork and exec.

Is it possible ?. Does standard say something on this ?.

Are there any limitations ?.


How exactly would you present a 50K argument to your program? The
concept is a little bizarre. The things normally passed through the
char *argv[] construct are filenames and options. Data to be
processed by the program is usually marshalled into files or other
streams which the program gets through the i/o system.

Better put the 50K in a file and pass the file's name to your
program or pass the contents of the file to your program through a
pipe to stdin.

--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #5
In article <yo********************@comcast.com>,
Joe Wright <jo********@comcast.net> wrote:
....
How exactly would you present a 50K argument to your program? The
concept is a little bizarre. The things normally passed through the
char *argv[] construct are filenames and options. Data to be
processed by the program is usually marshalled into files or other
streams which the program gets through the i/o system.


The short answer is: ls *

The longer answer is that my understanding is that on Unix/POSIX at any
rate, the limit is (in standard C [main()]) terms: argv+envp. I.e., the
size of the environment is often limited and the actual limit is the sum of
the two things (these are the two things that must be cached up somewhere
in the kernel to implement exec()).

Nov 14 '05 #6
In article <ch**********@yin.interaccess.com>,
Kenny McCormack <ga*****@interaccess.com> wrote:
How exactly would you present a 50K argument to your program?
The short answer is: ls *


That presents lots of smallish arguments, which isn't exactly what the OP
was asking about. I think a single 50k argument would be very unusual.

-- Richard
Nov 14 '05 #7
In article <ch***********@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <ri*****@cogsci.ed.ac.uk> wrote:
In article <ch**********@yin.interaccess.com>,
Kenny McCormack <ga*****@interaccess.com> wrote:
How exactly would you present a 50K argument to your program?

The short answer is: ls *


That presents lots of smallish arguments, which isn't exactly what the OP
was asking about. I think a single 50k argument would be very unusual.

-- Richard


Um, it is the total size (the sum of all the args lengths) that matters.

Nov 14 '05 #8
On 1 Sep 2004 09:02:41 -0700, Ch*******@aol.com (Mark R.Bannister)
wrote in comp.lang.c:
Je***********@physik.fu-berlin.de wrote in message news:<2p************@uni-berlin.de>...
James <ja***********@yahoo.co.uk> wrote:
consider :
int main (int argc, char * argv [ ]) {

}

In exec (2) ; Whose arguments which are passed to main.

What is the maximum size of the string.
argv[1] = "hello........." ;

How long can argv[1] point to. even though i know argv[i] is 4 bytes
pointer. How long can the string be ?.

I just want to send a 50K string as my process arguments (main's
args)
when i fork and exec.

Is it possible ?. Does standard say something on this ?.

Are there any limitations ?.


As far as I can tell, there's no requirement for the size of it in
the C standard (and I can't see any good reason why the standard
should require an upper limit). On the other hand, the operating
system will probably put a limit on the maximum size. E.g. the
POSIX standard SUSv3 requires that argv can use at least 4096 bytes
(but many Unices allow a lot more).

Regards, Jens


There isn't a limit on the length of an individual argument, only on
the length of the entire argument line has the ARG_MAX limit imposed
on it, defined in limits.h. The following makes an interesting
comparison on the size of ARG_MAX across various systems:


Perhaps you thought you were responding in comp.unix.programmer, and
not comp.lang.c. According to the C standard, a conforming compiler
is not allowed to define a macro in <limits.h>.

C language only, not POSIX here, please.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #9
ga*****@yin.interaccess.com (Kenny McCormack) writes:
In article <ch***********@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <ri*****@cogsci.ed.ac.uk> wrote:
In article <ch**********@yin.interaccess.com>,
Kenny McCormack <ga*****@interaccess.com> wrote:
How exactly would you present a 50K argument to your program?

The short answer is: ls *


That presents lots of smallish arguments, which isn't exactly what the OP
was asking about. I think a single 50k argument would be very unusual.

-- Richard


Um, it is the total size (the sum of all the args lengths) that matters.


The original poster asked about the maximum size of the string pointed
to by argv[1].

Any limits on argument size are system-specific and off-topic for
comp.lang.c. comp.unix.programer is probably a good place to ask.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #10
Richard Tobin <ri*****@cogsci.ed.ac.uk> wrote:
In article <ch**********@yin.interaccess.com>,
Kenny McCormack <ga*****@interaccess.com> wrote:
How exactly would you present a 50K argument to your program?

The short answer is: ls *


That presents lots of smallish arguments, which isn't exactly what the OP
was asking about. I think a single 50k argument would be very unusual.


Unusual, yes. A sign of bad programming/planning, probably.
Always avoidable in any real-world case, probably.
But, still:

awk "`cat big_awk_program`"

Yes yes, "-f" would be better! And the equivalent of "-f" would
probably be a better solution for the OP: the size limits of the
filesystem are likely to be much larger than the limits of the
commandline (and environment variables).

--Benjamin

Nov 14 '05 #11
Jack Klein <ja*******@spamcop.net> wrote in message news:<l3********************************@4ax.com>. ..
On 1 Sep 2004 09:02:41 -0700, Ch*******@aol.com (Mark R.Bannister)
wrote in comp.lang.c:
Je***********@physik.fu-berlin.de wrote in message news:<2p************@uni-berlin.de>...
James <ja***********@yahoo.co.uk> wrote:
> consider :
> int main (int argc, char * argv [ ]) { } In exec (2) ; Whose arguments which are passed to main. What is the maximum size of the string.
> argv[1] = "hello........." ; How long can argv[1] point to. even though i know argv[i] is 4 bytes
> pointer. How long can the string be ?. I just want to send a 50K string as my process arguments (main's
> args)
> when i fork and exec. Is it possible ?. Does standard say something on this ?. Are there any limitations ?.

As far as I can tell, there's no requirement for the size of it in
the C standard (and I can't see any good reason why the standard
should require an upper limit). On the other hand, the operating
system will probably put a limit on the maximum size. E.g. the
POSIX standard SUSv3 requires that argv can use at least 4096 bytes
(but many Unices allow a lot more).

Regards, Jens


There isn't a limit on the length of an individual argument, only on
the length of the entire argument line has the ARG_MAX limit imposed
on it, defined in limits.h. The following makes an interesting
comparison on the size of ARG_MAX across various systems:


Perhaps you thought you were responding in comp.unix.programmer, and
not comp.lang.c. According to the C standard, a conforming compiler
is not allowed to define a macro in <limits.h>.

C language only, not POSIX here, please.


Well excuse me for giving a real world answer.
Nov 14 '05 #12
In article <26*************************@posting.google.com> ,
Mark R.Bannister <Ch*******@aol.com> wrote:
....
Well excuse me for giving a real world answer.


The real world is OT here. I thought you understood that by now.

Nov 14 '05 #13
Ch*******@aol.com (Mark R.Bannister) writes:
Jack Klein <ja*******@spamcop.net> wrote in message
news:<l3********************************@4ax.com>. ..

[...]
Perhaps you thought you were responding in comp.unix.programmer, and
not comp.lang.c. According to the C standard, a conforming compiler
is not allowed to define a macro in <limits.h>.

C language only, not POSIX here, please.


Well excuse me for giving a real world answer.


Which real world would that be? There are plenty of real world
systems that support C but not POSIX, and there are newsgroups where
POSIX is topical.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: User | last post by:
Anyone have ideas which os command could be used to get the size of a file without actually opening it? My intention is to write a script that identifies duplicate files with different names. I...
9
by: matthurne | last post by:
I need to send just an array to a function which then needs to go through each element in the array. I tried using sizeof(array) / sizeof(array) but since the array is passed into the function,...
6
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello all, I recall several threads over the years about how reading file size cannot be done consistantly or portably, but I...
31
by: bilbothebagginsbab5 AT freenet DOT de | last post by:
Hello, hello. So. I've read what I could find on google(groups) for this, also the faq of comp.lang.c. But still I do not understand why there is not standard method to "(...) query the...
3
by: John Williams | last post by:
I need a way to determine how many characters are in a command line argument. Basically the code snippet looks like int main(int argc, char *argv) { openfiles(argv, argv, &infile, &outfile);...
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
0
by: shrik | last post by:
I have following error : Total giant files in replay configuration file are : File name : /new_file/prob1.rec Given file /new_file/prob1.rec is successfully verified. Splitting for giant file...
1
by: r3d dra6on | last post by:
I am trying to get the file size of a memory mapped I/O from the input file, and set that size to the output file. Right now the code below is stuck on the kernel mapping for the output. The...
20
by: Peter Olcott | last post by:
Is there any standard C++ way to determine the size of a file before it is read?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.