473,789 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8256
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***********@p hysik.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.goo gle.com ???...
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***********@p hysik.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************ ********@comcas t.com>,
Joe Wright <jo********@com cast.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**********@y in.interaccess. com>,
Kenny McCormack <ga*****@intera ccess.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**********@y in.interaccess. com>,
Kenny McCormack <ga*****@intera ccess.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.c om (Mark R.Bannister)
wrote in comp.lang.c:
Je***********@p hysik.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.progr ammer, 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.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #9
ga*****@yin.int eraccess.com (Kenny McCormack) writes:
In article <ch***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin <ri*****@cogsci .ed.ac.uk> wrote:
In article <ch**********@y in.interaccess. com>,
Kenny McCormack <ga*****@intera ccess.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.progr amer is probably a good place to ask.

--
Keith Thompson (The_Other_Keit h) 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

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

Similar topics

6
4014
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 have no trouble getting the names of all the files in the directory using the os.listdir() command, but that doesn't return the file size. In order to be identical, files must be the same size, so I want to use file size as the first criteria,...
9
10716
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, sizeof(array) is really sizeof(pointer to first element in array) and therefore doesn't solve my problem. If I can't calculate the size of the array, can I go through the elements without knowing the size and somehow test whether I'm off the end...
6
2482
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 don't remember any good reasons (not that I haven't read them, I'm sure, but it's more of a failure to hold them in my brain). Here is an attempt that I was commissioned to write, and I'd appreciate any comments and/or criticism (specific or...
31
3744
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 malloc package to find out how big an allocated block is". ( Question 7.27) Is there somwhere explained why - because it would seem to me, that free()
3
8699
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); cipher(&infile, &outfile, argv); return 0; } void cipher(fstream *infile, fstream *outfile, char key)
7
8135
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> #include<stdlib.h> #include<math.h>
0
6547
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 /new_file/prob1.rec started. Please wait.... In while loop of request searching *** glibc detected *** ./a.out: free(): invalid next size (normal): 0x099da890 *** ======= Backtrace: ========= /lib/libc.so.6
1
3256
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 program is suppose to map an input and an output and transfer all the writing from the input to the output with changes made to a specific ASCII character. The two problems I'm having trouble understanding are how to get the file size of the input to...
20
3575
by: Peter Olcott | last post by:
Is there any standard C++ way to determine the size of a file before it is read?
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.