Get PID from TID

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











up vote
3
down vote

favorite












I run iotop to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.



Unfortunately, while ps can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid. The best I can do is list TIDs and then grep the output. For example, if the thread id is 792, I can do



$ ps -eLf | grep ' 792 '


which works reasonably well, but is a little inelegant.



Is there a better way?







share|improve this question
























    up vote
    3
    down vote

    favorite












    I run iotop to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.



    Unfortunately, while ps can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid. The best I can do is list TIDs and then grep the output. For example, if the thread id is 792, I can do



    $ ps -eLf | grep ' 792 '


    which works reasonably well, but is a little inelegant.



    Is there a better way?







    share|improve this question






















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I run iotop to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.



      Unfortunately, while ps can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid. The best I can do is list TIDs and then grep the output. For example, if the thread id is 792, I can do



      $ ps -eLf | grep ' 792 '


      which works reasonably well, but is a little inelegant.



      Is there a better way?







      share|improve this question












      I run iotop to check on programs that are heavy disk users, in case I need to decrease their priority. Usually this is good enough, but iotop only shows thread ID (TID), and sometimes I want to know process ID (PID) so I can find out more about which process is responsible.



      Unfortunately, while ps can display TID (a.k.a SPID, LWP), it doesn't have a flag to take a list of TIDs the way it does for a list of PIDs with --pid. The best I can do is list TIDs and then grep the output. For example, if the thread id is 792, I can do



      $ ps -eLf | grep ' 792 '


      which works reasonably well, but is a little inelegant.



      Is there a better way?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 15 at 16:35









      Nathaniel M. Beaver

      180115




      180115




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          You can always do:



          ps -eLo pid= -o tid= | awk '$2 == 792 print $1'


          On Linux:



          $ readlink -f /proc/*/task/792/../..
          /proc/300


          Or with zsh:



          $ echo /proc/*/task/792(:h:h:t)
          300





          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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f430428%2fget-pid-from-tid%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            You can always do:



            ps -eLo pid= -o tid= | awk '$2 == 792 print $1'


            On Linux:



            $ readlink -f /proc/*/task/792/../..
            /proc/300


            Or with zsh:



            $ echo /proc/*/task/792(:h:h:t)
            300





            share|improve this answer
























              up vote
              5
              down vote



              accepted










              You can always do:



              ps -eLo pid= -o tid= | awk '$2 == 792 print $1'


              On Linux:



              $ readlink -f /proc/*/task/792/../..
              /proc/300


              Or with zsh:



              $ echo /proc/*/task/792(:h:h:t)
              300





              share|improve this answer






















                up vote
                5
                down vote



                accepted







                up vote
                5
                down vote



                accepted






                You can always do:



                ps -eLo pid= -o tid= | awk '$2 == 792 print $1'


                On Linux:



                $ readlink -f /proc/*/task/792/../..
                /proc/300


                Or with zsh:



                $ echo /proc/*/task/792(:h:h:t)
                300





                share|improve this answer












                You can always do:



                ps -eLo pid= -o tid= | awk '$2 == 792 print $1'


                On Linux:



                $ readlink -f /proc/*/task/792/../..
                /proc/300


                Or with zsh:



                $ echo /proc/*/task/792(:h:h:t)
                300






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 15 at 16:58









                Stéphane Chazelas

                280k53515847




                280k53515847






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430428%2fget-pid-from-tid%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

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

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay