From nobody Sat Jul 08 16:09:32 2023 X-Original-To: freebsd-hackers@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 4QywFh6XRdz4lKWR for ; Sat, 8 Jul 2023 16:09:44 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QywFh66QWz41T9; Sat, 8 Jul 2023 16:09:44 +0000 (UTC) (envelope-from theraven@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688832584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qf+W2/Wg6nJ4pgASAaDGYOuxgK8f2Y4Q+CRACrdCigo=; b=lUoi+s4+51AJ1aee7CVY9rzV6qEgnzixDidcXKVlxCsVgC/ovR09xofoQkYzeW7NP1Q/Xe 4LkgiCRZ9M1+hkUuUPJBl2wZQOJza8bzn/kCO3uJOYIDaj+s4tusy5WMazBLnVWb47Zcwm /QUl8hkSHk87twTolx0CAfwiQe8Ed6JvilAs4AaGMIsJqMIY241Qb2sVtg83xwEa4JHygi ixtdA7OMjhqt2o/jNSrviDbVSeR9wcEAkXRkSBGAOt0RxSUx4eP31Su7m6c5k1TqB7HQGZ TdCQM0ueN8wMFuNI7lvah3NIp4k8yuP/VLu9DIos4NOsxFjdl/3A2tksPGVptA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688832584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qf+W2/Wg6nJ4pgASAaDGYOuxgK8f2Y4Q+CRACrdCigo=; b=BYKn2Qb6Wt5fJ0+UNmryvvxMM1xxzyeZbNR5x4p2QzPhjgTGmw6lUM3YzyKPh3XOId+8mq Quxw6HYE52TDu7ouvSGawyqeVTWiabubTy878QGKviFLBYswVv4IjvJzEu5hpzOK2X71ra pi+z2UyUfO3da9NXqpuQr2tXX3CpbtG6renAT4A4eLgt54DNJ0FIibe9xirfGeQdF5ooPk X7pO3LNudR+gphYFZYcaSymrWTSA/Uks/M1r91BCdDO6A37Pz99ePAgeGAM7BTQbEM5n23 FeurBeRHgULMXXcTCsHmRplCoLlohQ4MIEtEeMh6vViQQjfTxg8CX9KBcqqvUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688832584; a=rsa-sha256; cv=none; b=Zn61Y//5bZ5rUl3iN2qgbr/4G1wGSf7t1RtsAy/bauLs6rJRbCdZHLg/dN5vkW0XPy9vZQ wk6loiI1UXOBzR78/SJ2LSgzdPjCU9SnWI3AmmkbTlx1mCg3p6wm+eJ5vcKGldfSyx11AV drKLLhgG9PbMNKErL0vi6Gq7xBDZa35HMTc6nPTXi5GBVLuNUJN+2IKDkC2eUU+NC0rwo2 6mOj9sbPz0egDrqdEyut2LQ2UIJTCLnWZ358+2uf+ivaYS7Dv+Wj2gwCBVpEjUXs9990Ww 7wyyOKFZxQ6Y3F1h+i+W6NKKswtVc3u0zIB7bY75kBuVsAf9+EaHQcjtmmGdSw== Received: from smtp.theravensnest.org (smtp.theravensnest.org [45.77.103.195]) (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) (Authenticated sender: theraven) by smtp.freebsd.org (Postfix) with ESMTPSA id 4QywFh50mfzGy6; Sat, 8 Jul 2023 16:09:44 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtpclient.apple (host86-141-212-56.range86-141.btcentralplus.com [86.141.212.56]) by smtp.theravensnest.org (Postfix) with ESMTPSA id B1E8E82BA; Sat, 8 Jul 2023 17:09:43 +0100 (BST) Content-Type: text/plain; charset=utf-8 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: What is the equivalent of the linux system call clone() on FreeBSD? From: David Chisnall In-Reply-To: Date: Sat, 8 Jul 2023 17:09:32 +0100 Cc: Yuri , Freebsd hackers list Content-Transfer-Encoding: quoted-printable Message-Id: <1866F21E-9EBC-48C3-A4FC-76A87895A6F1@FreeBSD.org> References: <693faa01-ca5e-a71c-4e5c-aea4f505ce54@tsoft.com> To: Brooks Davis X-Mailer: Apple Mail (2.3731.600.7) X-ThisMailContainsUnwantedMimeParts: N On 7 Jul 2023, at 22:53, Brooks Davis wrote: >=20 > clone is at least partially implemented in terms of rfork(2) flags. > It's not immediately obvious what the code is doing so I can't comment > if you'll be able to do what you need rfork if if you really need a > clone implementation. The Linux kernel doesn=E2=80=99t really have a notion of threads as = distinct from processes. This leads to some really annoying things (the = Linux equivalent of PROC_PDEATHSIG_CTL kills the child process when the = parent thread exits, even if it is not the main thread in the parent = process and the parent is still happily running). This means that clone = (/ clone3) is not just standing in for rfork, it is also standing in for = thr_new. Depending on exactly what you=E2=80=99re doing with clone, you may want = one of: - rfork - pdfork - thr_new Unfortunately, rfork does not have a pdfork-like variant (yet) and so = there are some combinations of rfork flags that don=E2=80=99t let you = use process descriptors (procfds in Linux), whereas in Linux these are = orthogonal. David