<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>41978</bug_id>
          
          <creation_ts>2022-02-17 02:00:22 +0300</creation_ts>
          <short_desc>Impossible to exit hsh-shell if processes left in background</short_desc>
          <delta_ts>2022-02-20 01:26:54 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>hasher</component>
          <version>unstable</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vitaly Chikunov">vt</reporter>
          <assigned_to name="Dmitry V. Levin">ldv</assigned_to>
          <cc>at</cc>
    
    <cc>glebfm</cc>
    
    <cc>iv</cc>
    
    <cc>ldv</cc>
    
    <cc>placeholder</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>207910</commentid>
    <comment_count>0</comment_count>
    <who name="Vitaly Chikunov">vt</who>
    <bug_when>2022-02-17 02:00:22 +0300</bug_when>
    <thetext>When developing or debugging something in the hasher (as in best practices) some process could be inadvertently left in background, causing failure exiting hsh-shell and working terminal hang. Example:
```
$ hsh-shell
builder@x86_64:/.in$ sleep 1234 &amp;
[1] 3978262
builder@x86_64:/.in$ exit
logout
```
Hangs there. It does not respond to ^C or ^Z, user cannot kill stray process, because it&apos;s different user.

Would be more rational if hasher kills such processes on exit. (Possible after user y/n request).

Or I&apos;m missing something?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208012</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2022-02-19 19:09:35 +0300</bug_when>
    <thetext>If hasher kills all lingering processes after the main process exit, some data may be lost.
If hasher doesn&apos;t kill all lingering processes after the main process exit, the wait may take too long.
Somebody is going to be unhappy whatever approach is chosen.
Maybe you want an option.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208013</commentid>
    <comment_count>2</comment_count>
    <who name="Vitaly Chikunov">vt</who>
    <bug_when>2022-02-19 19:49:27 +0300</bug_when>
    <thetext>I suggest user confirmation - kill (y/n) or wait longer.

Also, what data could be lost in the hasher?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208014</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2022-02-19 20:03:16 +0300</bug_when>
    <thetext>(In reply to Vitaly Chikunov from comment #2)
&gt; I suggest user confirmation - kill (y/n) or wait longer.

Snatch terminal from remaining hasher processes?

&gt; Also, what data could be lost in the hasher?

Any kind of data processed inside hasher.

For example, if the main process fails to wait for its child processes properly,
the killing spree would terminate these processes prematurely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208015</commentid>
    <comment_count>4</comment_count>
    <who name="Vitaly Chikunov">vt</who>
    <bug_when>2022-02-19 20:09:19 +0300</bug_when>
    <thetext>(Ответ для Dmitry V. Levin на комментарий #3)
&gt; (In reply to Vitaly Chikunov from comment #2)
&gt; &gt; I suggest user confirmation - kill (y/n) or wait longer.
&gt; 
&gt; Snatch terminal from remaining hasher processes?

Design is such that user cannot be asked?

&gt; &gt; Also, what data could be lost in the hasher?
&gt; 
&gt; Any kind of data processed inside hasher.
&gt; 
&gt; For example, if the main process fails to wait for its child processes
&gt; properly,
&gt; the killing spree would terminate these processes prematurely.

Thanks. But, how would you resolve this situation otherwise? (Without kill from root). Terminal is hanged, you don&apos;t kill processes, waited process user is different (and sometimes user do not have root to even kill).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208016</commentid>
    <comment_count>5</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2022-02-19 20:40:31 +0300</bug_when>
    <thetext>(In reply to Vitaly Chikunov from comment #4)
&gt; (Ответ для Dmitry V. Levin на комментарий #3)
&gt; &gt; (In reply to Vitaly Chikunov from comment #2)
&gt; &gt; &gt; I suggest user confirmation - kill (y/n) or wait longer.
&gt; &gt; 
&gt; &gt; Snatch terminal from remaining hasher processes?
&gt; 
&gt; Design is such that user cannot be asked?

If there is a terminal, everything is theoretically possible, but ...

&gt; &gt; &gt; Also, what data could be lost in the hasher?
&gt; &gt; 
&gt; &gt; Any kind of data processed inside hasher.
&gt; &gt; 
&gt; &gt; For example, if the main process fails to wait for its child processes
&gt; &gt; properly,
&gt; &gt; the killing spree would terminate these processes prematurely.
&gt; 
&gt; Thanks. But, how would you resolve this situation otherwise? (Without kill
&gt; from root). Terminal is hanged, you don&apos;t kill processes, waited process
&gt; user is different (and sometimes user do not have root to even kill).

... root is not needed, the user can kill its hasher-priv processes at this stage, they have the same uid as the user and they are visible via ps.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208025</commentid>
    <comment_count>6</comment_count>
    <who name="Vitaly Chikunov">vt</who>
    <bug_when>2022-02-20 00:59:31 +0300</bug_when>
    <thetext>&gt; ... root is not needed, the user can kill its hasher-priv processes at this
&gt; stage, they have the same uid as the user and they are visible via ps.

IC. It&apos;s worked. This is certainly non-obvious. But, the background process also got SIGKILL and terminal is messed up so I got to run `stty sane`.

So this solution, while exists and I didn&apos;t think of it, still as good as premature kill (and it&apos;s SIGKILL, not even SIGINT/SIGTERM which careful process could handle so save data).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208026</commentid>
    <comment_count>7</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2022-02-20 01:26:54 +0300</bug_when>
    <thetext>(In reply to Vitaly Chikunov from comment #6)
&gt; &gt; ... root is not needed, the user can kill its hasher-priv processes at this
&gt; &gt; stage, they have the same uid as the user and they are visible via ps.
&gt; 
&gt; IC. It&apos;s worked. This is certainly non-obvious. But, the background process
&gt; also got SIGKILL and terminal is messed up so I got to run `stty sane`.

That&apos;s because hasher-priv doesn&apos;t handle deadly signals, maybe it should handle them and restore the terminal.

&gt; So this solution, while exists and I didn&apos;t think of it, still as good as
&gt; premature kill (and it&apos;s SIGKILL, not even SIGINT/SIGTERM which careful
&gt; process could handle so save data).

Those who kill hasher-priv this way should make sure the data is safe.
Alternatively, one can terminate chrootuid2.sh first.

But all these methods are hacks, I&apos;d prefer to have an option for hsh-shell to wait for the specified number of seconds before calling it a day, or an option to specify an escape sequence similar to &quot;ssh -e&quot;.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>