Skip to content

pgrep: optimize command name copying

Baruch Siach requested to merge baruchsi/procps:pkill-optimize into master

strncpy() implementations in glibc and musl use memset() to zero the entire destination string past the source string length. This is hot code path that runs per PID. It makes strncpy() take more cycles than anything else.

Use memccpy() instead since it never touches the destination past the string terminator.

Signed-off-by: Baruch Siach baruch.siach@siklu.com

Merge request reports