public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Process limit in CYGWIN?
@ 2019-12-03 20:49 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
  2019-12-04 15:28 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin @ 2019-12-03 20:49 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

Hi all,

I have some test code that forks number of processes, and it looks like under Cygwin it fails at fork number 255 (plus minus one).

There is no getrlimit()'s RLIMIT_NPROC on Cygwin (unlike Unices) yet I see that my shell somehow shows the process limit of 256:
$ ulimit -u
256

I tried to look it up, but nothing useful comes up, so decided to ask the list -- it can be a lot quicker...

1. Is there a limit, indeed?
2. If there is, is it a documented feature?
3. Can it be found out programmatically?  (IDK how bash does it, since like I mentioned, RLIMIT_NPROC is nonexistent,
and even with bash, changing the "-u" limit produces EINVAL, and Cygwin source code confirms that, too.)
4. Can the limit be changed (dynamically or compile time)?

Thanks,
Anton


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Process limit in CYGWIN?
  2019-12-03 20:49 Process limit in CYGWIN? Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
@ 2019-12-04 15:28 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2019-12-04 15:28 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]

On Dec  3 20:49, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin wrote:
> Hi all,
> 
> I have some test code that forks number of processes, and it looks
> like under Cygwin it fails at fork number 255 (plus minus one).
> 
> There is no getrlimit()'s RLIMIT_NPROC on Cygwin (unlike Unices) yet I
> see that my shell somehow shows the process limit of 256: $ ulimit -u
> 256

IDK what bash is showing there, because RLIMIT_NPROC is undefined
on Cygwin.

> I tried to look it up, but nothing useful comes up, so decided to ask
> the list -- it can be a lot quicker...
> 
> 1. Is there a limit, indeed?

Yes, there is.

> 2. If there is, is it a documented feature?

No, it isn't.  Not that I'm aware of.  It's not exactly a feature, just
an artificial limitation, see below.

> 3. Can it be found out programmatically?  (IDK how bash does it, since
> like I mentioned, RLIMIT_NPROC is nonexistent,

RLIMIT_NPROC is different.  RLIMIT_NPROC is the maximum number of
threads / processes for the current user.  There's no known limit of
processes in Windows, but the number of threads per process is limited
to 1023 or 1024, not sure exactly.  There's no satisfactory mapping to
an RLIMIT_NPROC value.

The limit in Cygwin is quite different.  It's a hardcoded limit of 256
concurrent Cygwin child processes for a single parent process (no such
limit for child processes spawned using native Windows means).  The
reason is a static array holding process info for all children.

See winsup/cygwin/sigproc.cc, line 47ff.

> 4. Can the limit be changed (dynamically or compile time)?

It's hardcoded, so, no.  There's no *simple* way to change that other
than raising the size of that array generally (which I'd hate to do for
32 bit Cygwin).  The more sophisticated change would be to allocate the
array dynamically or even to convert this to a single or doubly linked
list.  We could store the info in the cygheap.  But that's quite a bit
of work and I'm rather limited in time ATM.  I'm very open to patches in
this regard, though...


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-04 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 20:49 Process limit in CYGWIN? Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-12-04 15:28 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).