* heap.cc (heap_init): Be slightly more aggressive when trying to allocate
heap. Change fatal error to avoid confusion with cygheap. * spawn.cc (linebuf::finish): New function. (linebuf::add): Cosmetic change. (spawn_guts): Only avoid building windows command line if the program being executed was actually mounted with -X. Don't return E2BIG if we hit the 32K size and we're executing a detected cygwin program. Just silently truncate the windows command line, instead.
This commit is contained in:
		| @@ -1,7 +1,20 @@ | |||||||
|  | 2005-09-09  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
|  | 	* heap.cc (heap_init): Be slightly more aggressive when trying to | ||||||
|  | 	allocate heap.  Change fatal error to avoid confusion with cygheap. | ||||||
|  |  | ||||||
|  | 	* spawn.cc (linebuf::finish): New function. | ||||||
|  | 	(linebuf::add): Cosmetic change. | ||||||
|  | 	(spawn_guts): Only avoid building windows command line if the program | ||||||
|  | 	being executed was actually mounted with -X.  Don't return E2BIG if we | ||||||
|  | 	hit the 32K size and we're executing a detected cygwin program.  Just | ||||||
|  | 	silently truncate the windows command line, instead. | ||||||
|  |  | ||||||
| 2005-09-08  Christopher Faylor  <cgf@timesys.com> | 2005-09-08  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
| 	* fhandler_serial.cc (fhandler_serial::tcgetattr): Just zero c_cflag | 	* fhandler_serial.cc (fhandler_serial::tcgetattr): Just zero c_cflag | ||||||
| 	here rather than clearing CBAUD after the fact. | 	here rather than clearing CBAUD after the fact. | ||||||
|  | 	* termios.cc (tcgetattr): Revert previous change. | ||||||
|  |  | ||||||
| 2005-09-08  Christopher Faylor  <cgf@timesys.com> | 2005-09-08  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
| @@ -265,7 +278,7 @@ | |||||||
| 	dirent_saw_dev. | 	dirent_saw_dev. | ||||||
| 	* dir.cc (opendir): Don't zero __flags here.  Push that responsibility | 	* dir.cc (opendir): Don't zero __flags here.  Push that responsibility | ||||||
| 	to opendir methods. | 	to opendir methods. | ||||||
| 	(seekdir): Preserve dirent_isrrot in __flags. | 	(seekdir): Preserve dirent_isroot in __flags. | ||||||
| 	(rewinddir): Ditto. | 	(rewinddir): Ditto. | ||||||
| 	* fhandler_disk_file.cc (fhandler_disk_file::opendir): Set | 	* fhandler_disk_file.cc (fhandler_disk_file::opendir): Set | ||||||
| 	dirent_isroot appropriately. | 	dirent_isroot appropriately. | ||||||
|   | |||||||
| @@ -73,11 +73,11 @@ heap_init () | |||||||
| 				     MEM_RESERVE, PAGE_READWRITE); | 				     MEM_RESERVE, PAGE_READWRITE); | ||||||
| 	  if (p) | 	  if (p) | ||||||
| 	    break; | 	    break; | ||||||
| 	  if ((reserve_size -= page_const) <= allocsize) | 	  if ((reserve_size -= page_const) < allocsize) | ||||||
| 	    break; | 	    break; | ||||||
| 	} | 	} | ||||||
|       if (!p) |       if (!p) | ||||||
| 	api_fatal ("couldn't allocate cygwin heap, %E, base %p, top %p, " | 	api_fatal ("couldn't allocate heap, %E, base %p, top %p, " | ||||||
| 		   "reserve_size %d, allocsize %d, page_const %d", | 		   "reserve_size %d, allocsize %d, page_const %d", | ||||||
| 		   cygheap->user_heap.base, cygheap->user_heap.top, | 		   cygheap->user_heap.base, cygheap->user_heap.top, | ||||||
| 		   reserve_size, allocsize, page_const); | 		   reserve_size, allocsize, page_const); | ||||||
|   | |||||||
| @@ -35,6 +35,7 @@ details. */ | |||||||
| #include "cygtls.h" | #include "cygtls.h" | ||||||
|  |  | ||||||
| #define LINE_BUF_CHUNK (CYG_MAX_PATH * 2) | #define LINE_BUF_CHUNK (CYG_MAX_PATH * 2) | ||||||
|  | #define MAXWINCMDLEN 32767 | ||||||
|  |  | ||||||
| static suffix_info std_suffixes[] = | static suffix_info std_suffixes[] = | ||||||
| { | { | ||||||
| @@ -231,16 +232,30 @@ class linebuf | |||||||
|   size_t alloced; |   size_t alloced; | ||||||
|   linebuf () : ix (0), buf (NULL), alloced (0) {} |   linebuf () : ix (0), buf (NULL), alloced (0) {} | ||||||
|   ~linebuf () {if (buf) free (buf);} |   ~linebuf () {if (buf) free (buf);} | ||||||
|   void add (const char *what, int len); |   void add (const char *what, int len) __attribute__ ((regparm (3))); | ||||||
|   void add (const char *what) {add (what, strlen (what));} |   void add (const char *what) {add (what, strlen (what));} | ||||||
|   void prepend (const char *what, int len); |   void prepend (const char *what, int len); | ||||||
|  |   void finish (bool) __attribute__ ((regparm (2))); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | void | ||||||
|  | linebuf::finish (bool cmdlenoverflow_ok) | ||||||
|  | { | ||||||
|  |   if (!ix) | ||||||
|  |     add ("", 1); | ||||||
|  |   else | ||||||
|  |     { | ||||||
|  |       if (ix-- > MAXWINCMDLEN && cmdlenoverflow_ok) | ||||||
|  | 	ix = MAXWINCMDLEN - 1; | ||||||
|  |       buf[ix] = '\0'; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| void | void | ||||||
| linebuf::add (const char *what, int len) | linebuf::add (const char *what, int len) | ||||||
| { | { | ||||||
|   size_t newix; |   size_t newix = ix + len; | ||||||
|   if ((newix = ix + len) >= alloced || !buf) |   if (newix >= alloced || !buf) | ||||||
|     { |     { | ||||||
|       alloced += LINE_BUF_CHUNK + newix; |       alloced += LINE_BUF_CHUNK + newix; | ||||||
|       buf = (char *) realloc (buf, alloced + 1); |       buf = (char *) realloc (buf, alloced + 1); | ||||||
| @@ -470,12 +485,12 @@ spawn_guts (const char * prog_arg, const char *const *argv, | |||||||
|       goto out; |       goto out; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   MALLOC_CHECK; |   bool wascygexec = real_path.iscygexec (); | ||||||
|   res = newargv.fixup (chtype, prog_arg, real_path, ext); |   res = newargv.fixup (chtype, prog_arg, real_path, ext); | ||||||
|   if (res) |   if (res) | ||||||
|     goto out; |     goto out; | ||||||
|  |  | ||||||
|   if (real_path.iscygexec ()) |   if (wascygexec) | ||||||
|     newargv.dup_all (); |     newargv.dup_all (); | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
| @@ -522,19 +537,12 @@ spawn_guts (const char * prog_arg, const char *const *argv, | |||||||
| 		one_line.add (a); | 		one_line.add (a); | ||||||
| 	      one_line.add ("\"", 1); | 	      one_line.add ("\"", 1); | ||||||
| 	    } | 	    } | ||||||
| 	  MALLOC_CHECK; |  | ||||||
| 	  one_line.add (" ", 1); | 	  one_line.add (" ", 1); | ||||||
| 	  MALLOC_CHECK; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|       MALLOC_CHECK; |       one_line.finish (real_path.iscygexec ()); | ||||||
|       if (one_line.ix) |  | ||||||
| 	one_line.buf[one_line.ix - 1] = '\0'; |  | ||||||
|       else |  | ||||||
| 	one_line.add ("", 1); |  | ||||||
|       MALLOC_CHECK; |  | ||||||
|  |  | ||||||
|       if (one_line.ix > 32767) |       if (one_line.ix >= MAXWINCMDLEN) | ||||||
| 	{ | 	{ | ||||||
| 	  debug_printf ("Command line too long (>32K), return E2BIG"); | 	  debug_printf ("Command line too long (>32K), return E2BIG"); | ||||||
| 	  set_errno (E2BIG); | 	  set_errno (E2BIG); | ||||||
| @@ -690,10 +698,8 @@ spawn_guts (const char * prog_arg, const char *const *argv, | |||||||
|   if (mode != _P_OVERLAY || !rc) |   if (mode != _P_OVERLAY || !rc) | ||||||
|     cygheap->user.reimpersonate (); |     cygheap->user.reimpersonate (); | ||||||
|  |  | ||||||
|   MALLOC_CHECK; |  | ||||||
|   if (envblock) |   if (envblock) | ||||||
|     free (envblock); |     free (envblock); | ||||||
|   MALLOC_CHECK; |  | ||||||
|  |  | ||||||
|   /* Set errno now so that debugging messages from it appear before our |   /* Set errno now so that debugging messages from it appear before our | ||||||
|      final debugging message [this is a general rule for debugging |      final debugging message [this is a general rule for debugging | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user