• Terminazione processo in background con "kill %1" dopo aver eseguito su

    From Davide Prina@21:1/5 to All on Sun Mar 10 12:40:01 2024
    sono riuscito ad usare waypipe usando un socket al posto di una
    connessione ssh, questo naturalmente soltanto per eseguire un
    programma come altro utente della stessa macchina.
    Mi sono fatto un piccolo script che, pur funzionando per quanto
    riguarda l'ottenimento del risultato voluto, ha qualche piccolo
    problema.

    In questa mail tratto il problema di come poter terminare un
    processo in background

    ecco un esempio:
    $ vi /tmp/test.txt &
    [1] 2904898
    $ kill %1

    faccio partire un job in background e poi lo termino.

    Però nel mio script ho qualcosa del genere

    #!/bin/bash
    [...]
    vi /tmp/test.txt &
    [...]
    su -c "$Comando" $AltroUtente
    [...]
    kill %1
    [...]


    Il kill %1 non funziona, anzi non funzionano neanche fg o jobs.
    Non capisco.
    il su -c non dovrebbe aprirmi un'altra shell per l'utente che sta
    eseguendo lo script o sbaglio?

    Naturalmente come soluzione stavo pensando di intercettare il pid
    del processo e usare questo per fare il kill. Però volevo capire
    perché quanto fatto non funziona.

    Ciao
    Davide

    --
    La mia privacy non è affar tuo
    https://noyb.eu/it
    - You do not have my permission to use this email to train an AI -
    If you use this to train your AI than you accept to distribute under AGPL license >= 3.0 all the model trained, all the source you have used to
    training your model and all the source of the program that use that model

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)