From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id E0B0D21731 for ; Mon, 3 Jun 2024 16:18:54 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1717424334; b=hD8N+YC3AIsrNo67JlkAg0q1CBLK2UrNRG1WSMcNooDlItn2TJXSKHVnAbrcrQ+FA93/6Cp5U7 VzoARLOKAgdTubC0reG/sRfVHCO6N9GupXxaha9ElY4yansOvlIOOycwoYs823RGVg+drZZemr aBhzCunFXUz7H1hEWCXtUYsVWScCOxoD3EBPMWoDz3Hopf0E6C3YvKtJ+CWlsInbsiXIcaIXR2 Jm7N4rUJIRj0vkz9PUIc9VbUFSp9F1OHFxw+ocTSIzWnCCFLPZgDn8W5wpo2g2XghhMrI+OAbq nxFZzAVTTXjdx8xE7xGXiDE5RHH8C9if1T1wPRlOR5bG3w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f179.google.com) smtp.remote-ip=209.85.208.179; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1717424334; bh=buGYcFgIb5c1uwEKmAqU1t+TbW4fsX7ZaRYik483uMU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=sOCSbQK4BfIfQRbl7PI+7UG+FV7Ybc2kMX/acF2zKLMS0p7QiI7NGA22I12DJpxXkUH7SI/DNc +ow3P0zqoGbGK73SgWNvAmHgrcI9eZXEs8Tre/WNTSu6Q1ma8cBaBrv9qCYGcgxdhwXOLv5Zhb N7crBoszCAryIF4NEl0qJd0iYUtaHQUKUuRJBcyatgcD95GVDJuPUSSXNMEPoQE56iGvGIAVSe mSwrKDwrT4i9PQldJwJz6dzXWf8RJmcl/YJUQHD/tIzPp+jQ2ntFpg5ajlTkj8F5L3eVAhCrSQ W+qDaN2xiRKi3WWagi2FKTb4x6xz65IrZnCZczXQgF5W3Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=WA/rK8GB9mcwJRPsjaKibf6s55Iywo1Bj1In9864CqM=; b=eTw2JpusF/U6sJvjWmZYF/aqEx f/1i5vyo726z77uNIPoEeX87rfOBiOPASP2IX03r+eb54Zuq3Yoiyh4w/beoEHRxn43Sdau9pEaAM +s4hwdSzFLB2Zc2AQwehrdESXeuYlxncS7QsrpmocXFBvN4lQOUP3esd9b4HMVd38nlIYpBghoOJ4 vBmXgi9xd+F/xD3WbAFBYRF6PjXRur7iYmzKP3DLcfcQpxH4CPMjDy/mXgBdYp6pNSZW6DMTma4Oz 7RXfaZ7zXQ8XDJTtL3c6pfOj9cMzIopkNUZnzrzo5BcPjCZefY6akSyotgmN1efe59RLPoQtYpR5z lK4ezCZA==; Received: by zero.zsh.org with local id 1sE8WU-000PkA-7N; Mon, 03 Jun 2024 14:18:54 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f179.google.com) smtp.remote-ip=209.85.208.179; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f179.google.com ([209.85.208.179]:53323) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1sE8Uw-000Oiq-Hc; Mon, 03 Jun 2024 14:17:19 +0000 Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e95a74d51fso66186941fa.2 for ; Mon, 03 Jun 2024 07:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717424237; x=1718029037; darn=zsh.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WA/rK8GB9mcwJRPsjaKibf6s55Iywo1Bj1In9864CqM=; b=hnR/jNsaKCjINttDsxKDCUSQuj4HivaYNdHmvbtXDHn3jgTYCLEsXnj5uQzTkaLYQE YBO+My6fnjIGpS/um6cbW1ZV3mlbZ/lIZ76wSezJQOVmNJYMwDZfAOC4mxCd4H22bNZp Bqd1E3lSFJ/JcgQ3W20H6pwYH3u5v7d0HyKL+zzxueEJs2gpK+v4yoHGWjZzxn7gQY9M RmZ2rQfRztmsT50PJvI2tIxcMjd7QIRz3ncl+KDTt2toJiY/SibB6/1f+d8wi23Mj+/v jY+13RSWwH0VJzNQjIs1TQXaFnOezEeTDzr3djPyJ+Ecv6taSGaJEc5kN4H/6yPtZz+A iytw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717424237; x=1718029037; h=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=WA/rK8GB9mcwJRPsjaKibf6s55Iywo1Bj1In9864CqM=; b=D3Rk7QCTBFeFkZHNXtoxoqZgDPT4bMnhovTE+1C0NJ9qhIYMxWKOjyCRVTvVHtUbwl QgExNWQVzFpadgrAf3OaNsYXvIa7fIQ2xIsFa75RxT3BbdHs6kg8q4HtgOulBHP7Qw29 lr8eMn1vEn66+vtI/EauUEeuN/i1Ea4iZd3nM6pTL0vdlXg0pg2FLugxZS9/KBnsSTBG 1NWvWOdTpvd4UIcNuq/36NQ12QnhUfjgcUsHnyK8mka8higciZumSPKTt0AkCRG69+0n mTLvNmGdfpGGh0ZE7Fr8eBGzLvxq3OzsErgLZ4JRcKApnb9ncCMuC0xoSRqyyriFUSst Cf5g== X-Gm-Message-State: AOJu0YyCgm4rcM4NgKu8JVkczYn6XhwCDZNbf0n8OQSDdxyMJtdysYhO +JdIWpitb035Xr5p8csakd6ugZ05iV/MTZ97KEZBoEmJABoE2kkjfGqNYhgH3zaeGkQeIips1gH Fullw6PbOsJ9+6Wt0qxvTu1isBqo= X-Google-Smtp-Source: AGHT+IF7o3gjOwaa8/za6JiEQjmrLnhwI0jgB55GfbgqdJZXnGl6F6kh8WXEpkiINrcWJOIykc6IARsSRI+616TJttw= X-Received: by 2002:a2e:3202:0:b0:2ea:83b1:bf70 with SMTP id 38308e7fff4ca-2ea951df832mr77409591fa.37.1717424236995; Mon, 03 Jun 2024 07:17:16 -0700 (PDT) MIME-Version: 1.0 References: <2bb9cec5-1293-4103-a73c-fd2a190cb65d@eastlink.ca> In-Reply-To: <2bb9cec5-1293-4103-a73c-fd2a190cb65d@eastlink.ca> From: "Mark J. Reed" Date: Mon, 3 Jun 2024 10:17:05 -0400 Message-ID: Subject: Re: exec To: Ray Andrews Cc: Zsh Users Content-Type: multipart/alternative; boundary="0000000000009331190619fcfd8e" X-Seq: 29980 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000009331190619fcfd8e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The *exec* builtin replaces the running shell with whatever program you run. The point is to avoid clogging the process table with shells that are just hanging out waiting to do nothing but exit as soon as their child process finishes. It's like tail-call optimization in programming languages= . In UNIX, the system call version of exec(2) is how _any_ program is run. Normally, when you type a command without the *exec* builtin in front of it, the shell first makes a copy of itself, and then that copy replaces itself with the program you want, using exec(2). Putting exec in front of it just causes the shell to skip the make-a-copy step and replace itself right away. In your case, the script exists to set things up in the environment and then run xfce4-session; there's nothing for it to do after xfce4-session completes, so it uses *exec* to tidy up. On Mon, Jun 3, 2024 at 10:11=E2=80=AFAM Ray Andrews wrote: > I've just recently come across 'exec' in a few scripts. No familiarity > with it. Running this: > > echo before exec > exec echo exec itself > echo after exec > > ... I find that whether in a script or a function it zaps the terminal an= d > there's no such place as 'after exec'. What are the uses of that? For > example the script that starts xfce4 'etc/xdg/xfce4/xinitrc' ends with th= is: > > exec xfce4-session > > ... so 'then what'? Hard to put the question into words, but I have a > sort of hanging feeling, I don't know where execution goes. For that > matter, neither do the xfce4 people know where it goes. ( Micro rant: yo= u > have yer systemd and yer xdg and yer dbus and God knows what else all > layered on top of each other and nobody knows what's actually happening.) > The question arises cuz I want to run scripts both just before and just > after an xfce4 session but nobody knows how that might be done. Not our > problem here of course, but if I had some insights into 'exec' it might > help. When, where and why do we 'exec' things? > > --=20 Mark J. Reed --0000000000009331190619fcfd8e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The=C2=A0exec=C2=A0builtin replace= s the running shell with whatever program you run.=C2=A0 The point is to av= oid clogging the process table with shells that are just hanging out waitin= g to do nothing but exit as soon as their child process finishes. It's = like tail-call optimization in programming languages.

In= UNIX, the system call version of exec(2) is how _any_ program is run. Norm= ally, when you type a command without the exec=C2=A0builtin in front= of it, the shell first makes a copy of itself, and then that copy replaces= itself with the program you want, using exec(2). Putting exec in front of = it just causes the shell to skip the make-a-copy step and replace itself ri= ght away.

In your case, the script exists to set t= hings up in the environment and then run xfce4-session; there's nothing= for it to do after xfce4-session completes, so it uses exec=C2=A0to= tidy up.


On Mon, Jun 3, 2024 at 10:11=E2=80=AFAM= Ray Andrews <rayandrews@eastl= ink.ca> wrote:
=20 =20 =20
I've just recently come across 'exec= ' in a few scripts.=C2=A0 No familiarity with it.=C2=A0 Running this:

echo before exec
exec echo exec itself
echo after exec

... I find that whether in a script or a function it zaps the terminal and there's no such place as 'after exec'. What = are the uses of that?=C2=A0 For example the script that starts xfce4 'etc/xdg/xfce4/xinitrc' ends with this:

=C2=A0=C2=A0=C2=A0=C2=A0 exec xfce4-session

... so 'then what'?=C2=A0 Hard to put the question into words= , but I have a sort of hanging feeling, I don't know where execution goes.=C2=A0 For that matter, neither do the xfce4 people know where i= t goes.=C2=A0 ( Micro rant: you have yer systemd and yer xdg and yer db= us and God knows what else all layered on top of each other and nobody knows what's actually happening.) The question arises cuz = I want to run scripts both just before and just after an xfce4 session but nobody knows how that might be done.=C2=A0 Not our proble= m here of course, but if I had some insights into 'exec' it mig= ht help.=C2=A0 When, where and why do we 'exec' things?=C2=A0


--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--0000000000009331190619fcfd8e--