Bug 241491

Summary: "ps -o lstart" broken for some locales
Product: Base System Reporter: Mikhail Teterin <mi>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Some People CC: rol, vegaio, yuripv
Priority: ---    
Version: 11.3-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Demonstrate the problem none

Description Mikhail Teterin freebsd_committer freebsd_triage 2019-10-25 17:09:18 UTC
Created attachment 208599 [details]
Demonstrate the problem

Depending on $LANG, the value printed for the STARTED column may be an empty string (or a sequence of blanks?)

Attached is a simple shell script listing both the broken and the Ok locales.
Comment 1 Mikhail Teterin freebsd_committer freebsd_triage 2019-10-25 17:25:13 UTC
Looks like the UTF-8, US-ASCII, ISO8859-1 and ISO8859-15 are all fine, while most others (like my own uk_UA.KOI8-U) are broken...
Comment 2 Yuri Pankov freebsd_committer freebsd_triage 2019-10-25 20:38:15 UTC
Apparently the problem isn't in ps itself and rather in libxo which talks about locales in general, but then uses a lot of handrolled conversions that apply only to ascii/utf-8. I'll look into it if no one beats me to it.
Comment 3 Yuri Pankov freebsd_committer freebsd_triage 2019-10-25 22:06:47 UTC
It turned out to be not as bad as I thought, I'll try proposing a patch upstream:

https://github.com/Juniper/libxo/pull/68

Please check if it fixes the issue for you.
Comment 4 Yuri Pankov freebsd_committer freebsd_triage 2020-06-07 08:01:04 UTC
*** Bug 229453 has been marked as a duplicate of this bug. ***
Comment 5 Yuri Pankov freebsd_committer freebsd_triage 2020-06-07 08:01:45 UTC
*** Bug 230068 has been marked as a duplicate of this bug. ***
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-06-07 08:21:41 UTC
A commit references this bug:

Author: yuripv
Date: Sun Jun  7 08:21:20 UTC 2020
New revision: 361887
URL: https://svnweb.freebsd.org/changeset/base/361887

Log:
  ps: use %hs instead of %s format specifiers

  Use %hs (locale-based encoding) instead of %s (UTF-8) format for
  strings that are expected to be in current locale encoding (date/time,
  process names/argument list).

  PR:		241491
  Reviewed by:	phil
  Differential Revision:	https://reviews.freebsd.org/D22160

Changes:
  head/bin/ps/keyword.c
  head/bin/ps/print.c
  head/bin/ps/ps.c