From nobody Thu Sep 11 18:50:21 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cN67d55ksz67HyQ; Thu, 11 Sep 2025 18:50:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cN67d4LnRz3gtt; Thu, 11 Sep 2025 18:50:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757616621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Fti1S3ya1b68HQbiFCRmFj6GBSgaJuLUpTsqOzHGO8Q=; b=ubQp6//kIfBmTcIo8b54PyYnqUnCwXOK242BJNfSl0yexYfftmU+XfOaqR3RYyY63N/YkA 0tAQKHUY+0VMlvlDeaY7ljuadumzRjWjm36cXHyD14gd2wk92GDkP/QYFeK+D5xvh6MXgw IFXA/1fqotu9sis6TM+0qJC1xseq+w87sJ4AfPrFwzJZJ7YU0A+6X6H7l968ge+5g3gm6n Ah2E1ex6ej9uIOGO6yP89KoaJ9q44U3VGZPbVvIb/vynfN/6n0bOceMNGtK6wcvbAqa+ka se8yTrhX+ApTA4sfb43rR4eUQgyB/rs2rDbNexcSYf+7WDC7Tv8Dqa8U1btLNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757616621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Fti1S3ya1b68HQbiFCRmFj6GBSgaJuLUpTsqOzHGO8Q=; b=gBIvhxfA2ajxjHYqHzdWRuWLOpjuhAcBIhZRQDtRWKdxFUBMEgBY917pJrvE+5nXVM5XCW cA6wCNyQ7dMqm5hqRIXXk/UtBINVtwHXL+5sjW4jzxkJv311BaxzyWwSrvOysTmzzkjcUw oDLGpUOOGk+xrHpHIoGmm3iI4Qr4tDWQhYJyfg+eRJ5wbURPwU7DjqNhYqYZfFmeSbCJ1r 49MEKbKY3jlyCm2n7JuDsXlgS48Tl3ZoHUqro1IT1G31ZSQ8NWYMOYbNKn4JcFVyssTCV+ I/m8I9lATeQXk91aQ6jj9K9nXup/NnvLjd5FX0qEeo90L4HmmxPiSMIIvNk2Eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757616621; a=rsa-sha256; cv=none; b=hWKWk9chNK4n5PVyTQzJsfrP114cKnkvcZazCsuZbAlm0SKg1OQ6lsvt2N0wboO+KcxlvP wLpLjL4Q3UkzwcrZd2cY22vD3C0Dt6pPQQa73Yb6xXNZE7NPNx8scabl/XD9hhR7LZh8sZ mX1ZXZn0EW0+VwrpV4a7fBRFtfMSjmUBHa30JWVYgTMlfJKXOt8f1dteCqMv1VIWToZgnH eaBl5jlu1BO2J5xlPzR39VhswyCi54ELpIil0k6HaLWOc8xmQFuO4hNAcf30Rk6hMNCKAN 3pQqq5W20n60NyjRiK4o4W01dwNHZ0srGF72h4cXFocB7sX3uQYcFV+kJG7fZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cN67d3nCgz3l7; Thu, 11 Sep 2025 18:50:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58BIoLDt092867; Thu, 11 Sep 2025 18:50:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58BIoLLE092864; Thu, 11 Sep 2025 18:50:21 GMT (envelope-from git) Date: Thu, 11 Sep 2025 18:50:21 GMT Message-Id: <202509111850.58BIoLLE092864@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 7f6da651e23f - stable/14 - flua: add posix.unistd.dup2() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7f6da651e23f4fbafac04ad77f1bdf74deec5882 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=7f6da651e23f4fbafac04ad77f1bdf74deec5882 commit 7f6da651e23f4fbafac04ad77f1bdf74deec5882 Author: Isaac Freund AuthorDate: 2025-05-05 09:03:37 +0000 Commit: Ed Maste CommitDate: 2025-09-11 15:09:58 +0000 flua: add posix.unistd.dup2() Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50176 (cherry picked from commit 909aa6781340f8c0b4ae01c6366bf1556ee2d1be) --- libexec/flua/modules/lposix.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libexec/flua/modules/lposix.c b/libexec/flua/modules/lposix.c index 47a1354aede9..43b9ee83673c 100644 --- a/libexec/flua/modules/lposix.c +++ b/libexec/flua/modules/lposix.c @@ -174,6 +174,39 @@ err: } +static int +lua_dup2(lua_State *L) +{ + int error, oldd, newd; + + enforce_max_args(L, 2); + + oldd = luaL_checkinteger(L, 1); + if (oldd < 0) { + error = EBADF; + goto err; + } + + newd = luaL_checkinteger(L, 2); + if (newd < 0) { + error = EBADF; + goto err; + } + + error = dup2(oldd, newd); + if (error >= 0) { + lua_pushinteger(L, error); + return (1); + } + + error = errno; +err: + lua_pushnil(L); + lua_pushstring(L, strerror(error)); + lua_pushinteger(L, error); + return (3); +} + static int lua_fnmatch(lua_State *L) { @@ -488,6 +521,7 @@ static const struct luaL_Reg unistdlib[] = { REG_SIMPLE(_exit), REG_SIMPLE(chown), REG_DEF(close, lua_pclose), + REG_SIMPLE(dup2), REG_SIMPLE(fork), REG_SIMPLE(getpid), REG_SIMPLE(pipe),