bugGNU Parallel - Bugs: bug #54339, parallel doesn't set its command...

 
 

bug #54339: parallel doesn't set its command name to parallel

Submitter:  Paulo Marcel Coelho Aragão <marcelpaulo>
Submitted:  Thu 19 Jul 2018 06:24:20 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Confirmed
Privacy:  Public Assigned to:  tange
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 23 Jul 2018 09:46:09 PM UTC, comment #4: 

CPAN module Linux::Prctl:

https://metacpan.org/pod/Sys%3a%3aPrctl

works on Xubuntu 18.04, I've just tested, running:


#!/usr/bin/env perl

use Linux::Prctl;

system 'ps -o pid,comm,args';
Linux::Prctl::set_name('bar');
system 'ps -o pid,comm,args';


Here's the output:


paulo:~/tmp$ ./foo
  PID COMMAND         COMMAND
11190 bash            /bin/bash
15658 foo             foo
18417 perl            perl ./foo
18418 ps              ps -o pid,comm,args
  PID COMMAND         COMMAND
11190 bash            /bin/bash
15658 foo             foo
18417 bar             perl ./foo
18419 ps              ps -o pid,comm,args


Paulo Marcel Coelho Aragão <marcelpaulo>
Mon 23 Jul 2018 09:24:42 PM UTC, comment #3: 

Actually, while working through this PerlMonks article, I realized that setting $0 changes both command line and process title:


paulo:~/tmp$ perl -e '$0="foo"; 1 while 1' &
[1] 15658
paulo:~/tmp$ ps -o comm,args
COMMAND         COMMAND
bash            /bin/bash
foo             foo
ps              ps -o comm,args


So, that's really not a solution.

Paulo Marcel Coelho Aragão <marcelpaulo>
Mon 23 Jul 2018 09:08:51 PM UTC, comment #2: 

Did a quick search and up to now only found out $0, but as you mentioned, it replaces the whole command line, and not just the command name (process title).

I get the feeling that there won't be a solution that works cross-platform.

But I'll keep digging.

Paulo Marcel Coelho Aragão <marcelpaulo>
Mon 23 Jul 2018 03:08:00 PM UTC, comment #1: 

This used to work a few years back, but newer versions of Perl/GNU/Linux(?) broke it.

See if you can find a reliable way that works - preferably cross platform.

A simple $0 seems to not be enough as it seems to each all arguments.



Ole Tange <tange>
Group administrator
Thu 19 Jul 2018 06:24:20 PM UTC, original submission:  

parallel doesn't explicitly set its command name to *parallel*, so it's set to the name of the interpreter, *perl*:


paulo:~/tmp$ parallel ps -o comm=COMMAND,args=CMDLINE \; echo ::: END
COMMAND         CMDLINE
bash            /bin/bash
perl            perl /usr/local/bin/parallel ps -o comm=COMMAND,args=CMDLINE ; echo ::: END
bash            /bin/bash -c ps -o comm=COMMAND,args=CMDLINE ; echo END
ps              ps -o comm=COMMAND,args=CMDLINE
END


As you can see, I meant the *command name* and not the *command line*.

Setting it to *parallel* would make it easier to kill it with:


killall parallel


I have observed that it seems to be common practice amidst Perl and Python programs to explicitly set their command name to the name of the program, otherwise it's set to the name of the interpreter. For instance, quodlibet is a Python program I use to manage my music collection, and it sets its command name:


paulo:~/tmp$ ps -e -o comm=COMMAND,args=CMDLINE | grep quodlibet
quodlibet       python3 /home/paulo/.local/bin/quodlibet


so I cann kill it synchronously easily with:


killall -w quodlibet


Paulo Marcel Coelho Aragão <marcelpaulo>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by tange (Posted a comment)
  • -email is unavailable- added by marcelpaulo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-07-23 tange StatusNone Confirmed
        Assigned toNone tange

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code