From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 2F7531F44D for ; Wed, 3 Apr 2024 17:20:03 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Eqd38I8W; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A76F3846402 for ; Wed, 3 Apr 2024 17:20:02 +0000 (GMT) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id BBE3A3858401 for ; Wed, 3 Apr 2024 17:19:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBE3A3858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BBE3A3858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712164784; cv=none; b=gFT/9LW2soOvKjEhBsqltHbZZwDomKIQV4HRGL/BeUV2x5/FWQ2u3BUNVpwP49x9JvaqYGZpvRQmy2wPIMlDC6OvLiOVLgF4zzzDt7dtFCzESyIWjBALBW2TCwWj7MivcId0YB4vhTsWMkHb4uioa2FIXKL0GwPweZait6AB6oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712164784; c=relaxed/simple; bh=KjmmhGc+qAvpFNpWp9cEApOFm4GAX4Bcyikcti1M53c=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=a/Vf+d7tvJM02u24SFFcXPB15oSJUYB6DbHsmAjPGQPqV4pshkKnoA1O4E9loIe42QcpysER1AwU3kGBnzrF/KArsEmwKDLzRL8Wi+W8apMW9E3eDuFRdLvF4VpoRcFDuuQXM6LDoAPQ8zTT/AOzgJR5UfBgq8m6yc9nG+1Abpo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-513dc9d6938so84035e87.2 for ; Wed, 03 Apr 2024 10:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712164780; x=1712769580; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=U2V6geBs42mSRSpC5xlGSj1aEXopDWkLBi+Wa1eF9HQ=; b=Eqd38I8WXoXVvO1dDQNGzi62DxQOREmo1QsJlEpxqj9FNycMIybg7jMh1KMjnPGmRU KhDjD2OaNVnhe0PmIEAWF2ePRKWoAnO83quDrFQGsGOyEATAEs/PePIB6BQ5Y8II9M0h X9GrZTZKvFxz6xlPtKaxPVf3Q07USyofX2xxY6u38SJadkV5EGw/8C+Td+ad66N4IABk wrAbeTaGmdZScW6wKM1/jtzoOM88zl4kxkZkJVS2BlfcoDgirBhe1Ed8dG2joJQH56ny irSg8Mdw30VmzmM2q0KHrLJzWt1dQtD2J98TMdw5pdR1Cqx3ld6gTX77llVZmolPZYxf waRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712164780; x=1712769580; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U2V6geBs42mSRSpC5xlGSj1aEXopDWkLBi+Wa1eF9HQ=; b=W8AB7yn17baS65v0ocFj2+FLCkAhU3Yn6783U0ZumBtaKn8i0sZLqCfZWmv/x/PZEN lzjdQmlOEs9B1h/Zs2jp6yUIeeyiazieTjFvT/oge7xSIFTuKn1cFoLo3UsTIWO9AqnP knIopX3r3mCNPLTFFB/N4MCtPz7wU2ElndA1LgqvfGwH/q7jCxX4TxSOVIa+IfievXcj T9J987E51LqfVf/75UreIEGyIUwrS0amXmJrDAt5rgQK378buJdpwavDZ0H4tUmA8OfL CaD4dfjcyvtSUKf+fe9u8Ix2GON7UXxMyMICO+FEBf2ecBXggu9lXFCo0jhMHpvwPIDQ y+WQ== X-Forwarded-Encrypted: i=1; AJvYcCWVczx/tw4042AWydXu+NpYocnl3UJosoMEonT1VwM7KW7xVUpFioq/2SFeN87qE/0o4WHC4DA9auqNrHbBa/kc4HYuEVd+1giH X-Gm-Message-State: AOJu0YwXnWkUDq8EXE6rDspACwhB0I1uTBOB0Fn3pg97v4N1GjcNbw4x +5waymEmWtX0TAitrbk3aHgd7jrrTRizFCUSm/mu5T68MvL9wvUJ6oFvKzseQPgF6GArqb9IFD4 VXLS1pvTMTiDXzMf9wz5a6g/K5pQ= X-Google-Smtp-Source: AGHT+IG6Kx3E/AIExoFSMcZql48Qti1jY4bgk+ewML/NFk3QOysDqI/UoGIDSFEqXt2KJ+bAZJq7/5J2jXtreqWgfu4= X-Received: by 2002:ac2:5471:0:b0:513:a732:4878 with SMTP id e17-20020ac25471000000b00513a7324878mr102360lfn.41.1712164779844; Wed, 03 Apr 2024 10:19:39 -0700 (PDT) MIME-Version: 1.0 References: <9831afe6-958a-fbd3-9434-05dd0c9b602a@draigBrady.com> <317fe0e2-8cf9-d4ac-ed56-e6ebcc2baa55@cs.wisc.edu> <8c490a55-598a-adf6-67c2-eb2a6099620a@cs.wisc.edu> <88a67f36-2a56-a838-f763-f55b3073bb50@lando.namek.net> <2791ad90-a871-474d-89dd-bc6b20cdd1f2@case.edu> In-Reply-To: <2791ad90-a871-474d-89dd-bc6b20cdd1f2@case.edu> From: Zachary Santer Date: Wed, 3 Apr 2024 13:19:27 -0400 Message-ID: Subject: Re: Examples of concurrent coproc usage? To: chet.ramey@case.edu Cc: Carl Edquist , bug-bash , libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org On Wed, Apr 3, 2024 at 10:32=E2=80=AFAM Chet Ramey wr= ote: > > How long should the shell defer deallocating the coproc after the process > terminates? What should it do to make sure that the variables don't hang > around with invalid file descriptors? Or should the user be responsible f= or > unsetting the array variable too? (That's never been a requirement, > obviously.) For sake of comparison, and because I don't know the answer, what does bash do behind the scenes in this situation? exec {fd}< <( some command ) while IFS=3D'' read -r line <&"${fd}"; do # do stuff done {fd}<&- Because the command in the process substitution isn't waiting for input, (I think) it could've exited at any point before all of its output has been consumed. Even so, bash appears to handle this seamlessly. As the programmer, I know ${fd} contains an fd that's no longer valid after this point, despite it not being unset.