X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:in-reply-to; q=dns; s=
	default; b=OrWwg4q6UI92pHLFOOTwzgMw4kr4UPBEGZrCTrJyHJR4Cnr8/E3vj
	nG7E2lnaVYPic4LHNandrUahY/UWhSY7ukiNota5OTXcEzuzxQCXSxGaGy4DYZZL
	LTukvx2p0tO3f8w3XQFc7drEIfMBM9O5BsV60mGR2jipcLsQkhJ+Dg=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:in-reply-to; s=default;
	 bh=v95V+na9EfUs+DDBkzoEszQnMp8=; b=EICLzQJ5BGgKLf6SnLIChZHQ+fU5
	Fsj8n6BSxRQhgeQ6TgKKcxL+XyrpV2ZwtsIQAWX3n1AjBm6/6/WUvORkDmF9IGaK
	+qHRsYebQfYLwEB7+3wBCi8a5uXBewKn8L1dsWvYIvBBBV3RYSXru5awWKdB5ubU
	JLDawSC3L7KbIOo=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-105.0 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Lavrentiev, NCBI, lavrentiev, nih
X-HELO: mout.kundenserver.de
Date: Wed, 4 Dec 2019 16:28:10 +0100
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Process limit in CYGWIN?
Message-ID: <20191204152810.GE3337@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <BN7PR09MB27395C1329EBF5C41A47DF54A5420@BN7PR09MB2739.namprd09.prod.outlook.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;	protocol="application/pgp-signature"; boundary="+KJYzRxRHjYqLGl5"
Content-Disposition: inline
In-Reply-To: <BN7PR09MB27395C1329EBF5C41A47DF54A5420@BN7PR09MB2739.namprd09.prod.outlook.com>
User-Agent: Mutt/1.12.1 (2019-06-15)

--+KJYzRxRHjYqLGl5
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Dec  3 20:49, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin wrote:
> Hi all,
>=20
> 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).
>=20
> 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...
>=20
> 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

--=20
Corinna Vinschen
Cygwin Maintainer

--+KJYzRxRHjYqLGl5
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl3n0IoACgkQ9TYGna5E
T6D+ChAAlZcw00oELMwTd1hrLLG03NVuBLWIxa0vmUPMgmwEhy9zYIbgaxUsXNlT
/v2Dg4SwGs5lmyGd6fMPNjJL+mChyIzmlXCQZGGzMwIiuBv+/fUzj2477akjLO6m
rZ7/7mf55wbnwmLcQ5Seknv6UDkG8ow6JTdLxuSTPd3aK2i79HX/Dy9auRPK34vg
AGXDunU8uPq4yTpYp7+gkQQKQojjsBxqZNlnJZ1TcD3wcPa7lNnd6IZaaJhOFWYu
m4+eI/jtKDWmd/yPuFb9TkpztiTvq/B8Omjr6dwSbNMtY/1pmaZYRoJ9gwU2GAVy
d6u/LWXBZ/cdCvGrtPqqwu8/nSJBRsepfBkVrdT0lraxRFS6YTT7x7dqfq+dTKLU
ZPN7I6d06TnK+h7aY6GEnNZSwx1LEEna9mEnhJto3jx8elg1GxDQ/xJ1s0fuzutQ
jHme1nxzmPbbBYvKAD4oGWoSZ4gZyz0S8eBSEDNQX4JMzwrY+tY6dl2H22O9x3BV
mGGBgGQKnfUq4G8x+ug08s6ciZJSINgh9MShVM3xGLfoEb/qa0Rw6csLXpHFaMSI
Ht+m24W/OExXkhpnZRrT7e+3b7dUWMqUg9WiMn6UyhoF5F93TKL+Nrp16DzOqNWO
IFzHp8g55ybKiDJ5Jey1N8EbbSgCHsK+X9PacRx5JLHLM+n6Ock=
=b0JI
-----END PGP SIGNATURE-----

--+KJYzRxRHjYqLGl5--
