2 * Copyright (C) 2015-2020 "IoT.bzh"
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <sys/prctl.h>
22 #include "process-name.h"
24 int process_name_set_name(const char *name)
26 return prctl(PR_SET_NAME, name);
29 int process_name_replace_cmdline(char **argv, const char *name)
31 char *beg, *end, **av, c;
33 /* update the command line */
37 return -1; /* no command line update required */
48 return -1; /* nothing to change */
51 /* patch the command line */
54 while (beg != end && (c = *name++)) {
62 /* terminate last arg */
65 /* update remaining args (for keeping initial length correct) */
68 /* fulfill last arg with spaces */