Re: [PATCH v2] taskset: Accept 0 pid for current process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 01, 2025 at 08:35:11AM +0200, Jesse Rosenstock wrote:
> A reasonable alternative would be to interpret just `taskset` (currently
> an error) as printing the current mask.  This seems less orthogonal,
> and a better use may be found for plain `taskset` in the future.

Unfortunately, all schedutils have an odd command-line semantic.

>                 case 'p':
> -                       pid = strtopid_or_err(argv[argc - 1],
> _("invalid PID argument"));
> +                       /*
> +                        * Like strtopid_or_err() but accept 0 for this process,
> +                        * like sched_getaffinity()/sched_setaffinity() do.
> +                        */
> +                       pid = (pid_t) str2num_or_err(
> +                               argv[argc - 1], 10, _("invalid PID argument"),
> +                               0, SINT_MAX(pid_t));

chrt uses:

                     /* strtopid_or_err() is not suitable here; 0 can be passed.*/
                        ctl->pid = strtos32_or_err(argv[argc - 1], _("invalid PID argument"));

 would be this enough?

> +                       if (pid == 0)
> +                               pid = getpid();

Yes, this is probably better than make many other changes to the code.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux