killall for this terminal only

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












When debugging I often use killall to kill a process. This is really a bad habit because there might be more processes running of the same name on the system.



Normally the process I want to kill is a descendant from the same parent (or grandparent) as killall is started from. Often I want to kill a program started in the same terminal or a terminal in another tab (in Konsole).



Is there a way to tell killall (or another killer) to limit the scope to processes started from this terminal or processes that are descendants from the same (grand)parent?










share|improve this question





















  • Would this be an acceptable alternative? ps selects processes at the terminal scope by default, which could then be piped to xargs kill.
    – Haxiel
    Nov 22 at 9:40














up vote
1
down vote

favorite












When debugging I often use killall to kill a process. This is really a bad habit because there might be more processes running of the same name on the system.



Normally the process I want to kill is a descendant from the same parent (or grandparent) as killall is started from. Often I want to kill a program started in the same terminal or a terminal in another tab (in Konsole).



Is there a way to tell killall (or another killer) to limit the scope to processes started from this terminal or processes that are descendants from the same (grand)parent?










share|improve this question





















  • Would this be an acceptable alternative? ps selects processes at the terminal scope by default, which could then be piped to xargs kill.
    – Haxiel
    Nov 22 at 9:40












up vote
1
down vote

favorite









up vote
1
down vote

favorite











When debugging I often use killall to kill a process. This is really a bad habit because there might be more processes running of the same name on the system.



Normally the process I want to kill is a descendant from the same parent (or grandparent) as killall is started from. Often I want to kill a program started in the same terminal or a terminal in another tab (in Konsole).



Is there a way to tell killall (or another killer) to limit the scope to processes started from this terminal or processes that are descendants from the same (grand)parent?










share|improve this question













When debugging I often use killall to kill a process. This is really a bad habit because there might be more processes running of the same name on the system.



Normally the process I want to kill is a descendant from the same parent (or grandparent) as killall is started from. Often I want to kill a program started in the same terminal or a terminal in another tab (in Konsole).



Is there a way to tell killall (or another killer) to limit the scope to processes started from this terminal or processes that are descendants from the same (grand)parent?







kill






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 8:42









Ole Tange

11.9k1450105




11.9k1450105











  • Would this be an acceptable alternative? ps selects processes at the terminal scope by default, which could then be piped to xargs kill.
    – Haxiel
    Nov 22 at 9:40
















  • Would this be an acceptable alternative? ps selects processes at the terminal scope by default, which could then be piped to xargs kill.
    – Haxiel
    Nov 22 at 9:40















Would this be an acceptable alternative? ps selects processes at the terminal scope by default, which could then be piped to xargs kill.
– Haxiel
Nov 22 at 9:40




Would this be an acceptable alternative? ps selects processes at the terminal scope by default, which could then be piped to xargs kill.
– Haxiel
Nov 22 at 9:40










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










If you want to kill all processes from this session (processes which have the current tty as their controlling terminal):



tty=`tty`; pkill -t "$tty#/dev/"


Or even simpler:



pkill -s 0


According to pkill(1):




-s, --session sid,...

Only match processes whose process session ID is listed. Ses-
sion ID 0 is translated into pgrep's or pkill's own session ID.



Both the -t and the -s options could be combined (ANDed) with a pattern and other options, eg. pgrep -s0 -x foo for the processes from this session named exactly foo. Unfortunately, neither pgrep nor pkill support complex, tcpdump-style predicates.






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483386%2fkillall-for-this-terminal-only%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    If you want to kill all processes from this session (processes which have the current tty as their controlling terminal):



    tty=`tty`; pkill -t "$tty#/dev/"


    Or even simpler:



    pkill -s 0


    According to pkill(1):




    -s, --session sid,...

    Only match processes whose process session ID is listed. Ses-
    sion ID 0 is translated into pgrep's or pkill's own session ID.



    Both the -t and the -s options could be combined (ANDed) with a pattern and other options, eg. pgrep -s0 -x foo for the processes from this session named exactly foo. Unfortunately, neither pgrep nor pkill support complex, tcpdump-style predicates.






    share|improve this answer


























      up vote
      2
      down vote



      accepted










      If you want to kill all processes from this session (processes which have the current tty as their controlling terminal):



      tty=`tty`; pkill -t "$tty#/dev/"


      Or even simpler:



      pkill -s 0


      According to pkill(1):




      -s, --session sid,...

      Only match processes whose process session ID is listed. Ses-
      sion ID 0 is translated into pgrep's or pkill's own session ID.



      Both the -t and the -s options could be combined (ANDed) with a pattern and other options, eg. pgrep -s0 -x foo for the processes from this session named exactly foo. Unfortunately, neither pgrep nor pkill support complex, tcpdump-style predicates.






      share|improve this answer
























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        If you want to kill all processes from this session (processes which have the current tty as their controlling terminal):



        tty=`tty`; pkill -t "$tty#/dev/"


        Or even simpler:



        pkill -s 0


        According to pkill(1):




        -s, --session sid,...

        Only match processes whose process session ID is listed. Ses-
        sion ID 0 is translated into pgrep's or pkill's own session ID.



        Both the -t and the -s options could be combined (ANDed) with a pattern and other options, eg. pgrep -s0 -x foo for the processes from this session named exactly foo. Unfortunately, neither pgrep nor pkill support complex, tcpdump-style predicates.






        share|improve this answer














        If you want to kill all processes from this session (processes which have the current tty as their controlling terminal):



        tty=`tty`; pkill -t "$tty#/dev/"


        Or even simpler:



        pkill -s 0


        According to pkill(1):




        -s, --session sid,...

        Only match processes whose process session ID is listed. Ses-
        sion ID 0 is translated into pgrep's or pkill's own session ID.



        Both the -t and the -s options could be combined (ANDed) with a pattern and other options, eg. pgrep -s0 -x foo for the processes from this session named exactly foo. Unfortunately, neither pgrep nor pkill support complex, tcpdump-style predicates.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 at 10:51

























        answered Nov 22 at 9:43









        mosvy

        4,831322




        4,831322



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483386%2fkillall-for-this-terminal-only%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?