summaryrefslogtreecommitdiffstats
path: root/nsframework/common_library/client/include/native_service/cl_process.h
blob: 6a9adbfbcb1d200d02add33ca8a9d8b6e239fe40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _cl_process_h_  // NOLINT(build/header_guard)
#define _cl_process_h_  // NOLINT(build/header_guard)

#include <sys/types.h>

#define CL_PROCESSS_ATTR_HOLD_FDS_NUM 8

#define CL_INTFY_FILENAME_FORMAT "/tmp/intfy_%05d"

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessAttr_t
/// \~english @par Brief
///        Process attribute structure
/////////////////////////////////////////////////////////////////////////////////////
typedef struct {
  char body[148];  ///< process attribute
} CL_ProcessAttr_t;

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCleanupInfo_t
/// \~english @par Brief
///        Child-process attribute structure
/////////////////////////////////////////////////////////////////////////////////////
typedef struct {
  pid_t pid;       ///< child-process ID
  int code;        ///< signal code
  int status;      ///< end status or signal
} CL_ProcessCleanupInfo_t;

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessSchedPolicy_t
/// \~english @par Brief
///        Schedule policy
/////////////////////////////////////////////////////////////////////////////////////
typedef enum {
  CL_PROCESS_SCHED_POLICY_OTHER = 0,  ///< TSS
  CL_PROCESS_SCHED_POLICY_RR,         ///< Round robin
  CL_PROCESS_SCHED_POLICY_FIFO,       ///< FIFO
} CL_ProcessSchedPolicy_t;

typedef struct {
  char body[20];
} CL_ThreadAttr_t;

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttr_t
/// Cgroup attribute structure
/////////////////////////////////////////////////////////////////////////////////////
typedef struct {
  char body[24];  ///< Cgroup attribute
} CL_ProcessCreateCgroupAttr_t;

#ifdef __cplusplus
extern "C" {
#endif
/**
 * @file cl_process.h
 * @brief \~english This file contains the base api,enum and struct of cl_process.
 */

/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup native_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup common_library
 *  @ingroup native_service
 *  @{
 */

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessInit
/// \~english @par Brief
///        Initialize the process
/// \~english @retval int file  descriptor
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Prerequisites are nothing.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - Failed to set up process prctl, -1 is returned.
///        - Failed to set the signal set to the empty set sigemptyset, -1 is returned.
///        - Failed to add a signal to the signal mask sigaddset, -1 is returned.
///        - Failed to set sigprocmask, -1 is returned.
///        - Failed to create a scripter in the file for signal acceptance signalfd, -1 is returned.
/// \~english @par Detail
///        This API must be called before createing a thread.
///        Therefore, it is recommended that this API be called from within the main() function immediately after the API started.\n
///        Initialize the process.\n
///        The retuen value fd is assumed to be poll/select and used for waiting for event.\n
///        An ready occurs when the child process terminates.\n
///        Call process name setting(\ref CL_ProcessCreateAttrSetName) uniformly
///        because it is applied only to the number of architecture after exec.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessInit(void);  // NOLINT(readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreate
/// \~english @par Brief
///        Create the process
/// \~english @param [in] file
///        const char*   -
/// \~english @param [in] argv[]
///        char* const  -
/// \~english @param [in] envp[]
///        char* const
/// \~english @param [in] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval int Success(PID)
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Need to be running CL_ProcessInit.
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the executable name (file) in the argument is NULL, set errno to EINVAL, -1 is returned.
///        - When the ARG parameter (argv[]) in the argument is NULL, set errno to EINVAL, -1 is returned.
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When memory (malloc) of the data storagee area of the environment variable parameter (envp[]) specified
///          by the arguments fails, set errno to EINVAL, -1 is returned.
///        - When memory (malloc) of the data control area of the environment variable parameter (envp[]) specified
///          by the arguments fails, set errno to EINVAL, -1 is returned.
///        - Process creation (fork) fail, -1 is returned.
///        - Process CPU affinity masking (sched_setaffinity) fail, -1 is returned.
///        - When the character string output processing (snprintf) for process creation fail, -1 is returned.
///        - When the character string output processing (snprintf) for PID setting of cgroup fail, -1 is returned.
///        - Failure to allocate the area fo sstoring the path name of cgroup (malloc), -1 is returned.
///        - Failure to open file descriptor (open) of cgroup, -1 is returned.
///        - Failure to write file descriptor (write) of cgroup, -1 is returned.
/// \~english @par Detail
///        - This API must be called before createing a thread.
/// \~english @par
///        Create the process.\n
///        The ARG parameter (argv[]) specified in the argment must satisfy the following conditions:\n
///        - Can not be omitted.\n
///        - The first argument must specify a pointer o the filename to be executed.\n
///        - An array of pointer to NULL terminated strings.\n
///        - Arrays must be terminated by NULL pointer.\n
/// \~english @par
///        Enviroment-variable parameters (envp[]) specified in arguments mus satisfy the following condiions:\n
///        - When NULL is specified, the parent process inherits the parent process's environment variables.\n
///        - An array of pointer to NULL terminated strings.\n
///        - Arrays must be terminated by NULL pointer.\n
/// \~english @par
///        Be aware of the following.\n
///        - Processing continues without interrupting event if setrlimit() fail.\n
///        - System call access() checks whether or not there is access privilege,
///          but returns PID regardless of the access privilege status.
///          (If the process does not have access privilege, 100 retries are executed at 100 microseconds.)
/// \~english @par
///        Since the process attribute of a process cannot be changed during processing,
///        if it is necessary to change the process attribute,
///        it is necessary to call the following API and change the process attribute before calling this API.\n
///          - CL_ProcessCreateAttrInit Initialize process attribute
///          - CL_ProcessCreateAttrSetCgroup Setting process attribute (Cgroup)
///          - CL_ProcessCreateAttrSetDisableCloseFds Setting process attribute (stop compulsion FD close)
///          - CL_ProcessCreateAttrSetGid Setting process attribute (group ID)
///          - CL_ProcessCreateAttrSetGroup Setting process attribute (process group)
///          - CL_ProcessCreateAttrSetHoldFds Setting process attribute (maintain FD)
///          - CL_ProcessCreateAttrSetName Setting process attribute (process name)
///          - CL_ProcessCreateAttrSetSchedule Setting process attribute (schedule policy and priority)
///          - CL_ProcessCreateAttrSetStackSize Setting process attribute (Stack Size)
///          - CL_ProcessCreateAttrSetUid Setting process attribute (user ID)
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        CL_ProcessTerminate, CL_ProcessTerminateGroup
///        CL_ProcessCreateAttrInit, CL_ProcessCreateAttrSetCgroup,
///        CL_ProcessCreateAttrSetDisableCloseFds, CL_ProcessCreateAttrSetGid,
///        CL_ProcessCreateAttrSetGroup, CL_ProcessCreateAttrSetHoldFds,
///        CL_ProcessCreateAttrSetName, CL_ProcessCreateAttrSetSchedule,
///        CL_ProcessCreateAttrSetStackSize, CL_ProcessCreateAttrSetUid
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreate(const char *file, char * const argv[], char * const envp[],  // NOLINT(readability/nolint)
                     const CL_ProcessAttr_t *attr);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrInit
/// \~english @par Brief
///        Initialize process attribute
/// \~english @param [out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Prerequisites are nothing.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Initilize the CL_ProcessAttr_t structure that stores process attribute.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Method(Async) / Fire and Forget / Broadcast / Sync / Set Get / Open Close / Request Notify / No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrInit(CL_ProcessAttr_t *attr);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetName
/// \~english @par Brief
///        Set process name in process attribute
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] name
///        const char*   - process name (max length 16byte)
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When the pointer (name) to the character string hat stores the process name specified
///          by the argument is NULL, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process name to process attribute.\n
///        The charactr string that stores the process name specified by the argument must satisfy the following conditions:\n
///        - Terminated by a NULL.\n
///        - The maximum lengthof character string is 16 byte including the termination character.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetName(CL_ProcessAttr_t *attr, const char *name);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetUid
/// \~english @par Brief
///        Set process attribute to user ID
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] uid
///        uid_t   - user ID
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to user ID.\n
///        When UINT_MAX is set for the user ID,
///        the user ID is set to 0 in the process attribute in the processing of CL_ProcessCreate().\n
///        When 0 is set for the user ID,
///        it is not reflected in the process attribute becose if is played by the process of CL_ProcessCreate().\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetUid(CL_ProcessAttr_t *attr, uid_t uid);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetGid
/// \~english @par Brief
///        Set process attribute to group ID
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] gid
///        gid_t   - Group ID
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to group ID.\n
///        When 0 is set for the group ID,
///        it is not reflected in the process attribute becose if is played by the process of CL_ProcessCreate().\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetGid(CL_ProcessAttr_t *attr, gid_t gid);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetSchedule
/// \~english @par Brief
///        Set process attribute to schedule policy and priority
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] policy
///        CL_ProcessSchedPolicy_t   - schedule policy
/// \~english @param [in] priority
///        int   - priority
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @par
///        enum CL_ProcessSchedPolicy_t Variable
/// \~english @code
///                 typedef enum {
///                   CL_PROCESS_SCHED_POLICY_OTHER = 0,  // TSS
///                   CL_PROCESS_SCHED_POLICY_RR,         // Round-robin
///                   CL_PROCESS_SCHED_POLICY_FIFO,       // FIFO
///                 } CL_ProcessSchedPolicy_t;
///            @endcode
/// \~english @par
///        target to priority
///        - -20~19 : CL_PROCESS_SCHED_POLICY_OTHER
///        -   1~99 : CL_PROCESS_SCHED_POLICY_RR or CL_PROCESS_SCHED_POLICY_FIFO
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When the schedule policy (policy) specified in the parameter is CL_PROCESS_SCHED_POLICY_RR
///          and the priority (priority) is other than 1 to 99, set errno to EINVAL, -1 is returned.
///        - When the schedule policy (policy) specified in the parameter is CL_PROCESS_SCHED_POLICY_FIFO
///          and the priority (priority) is other than 1 to 99, set errno to EINVAL, -1 is returned.
///        - Incorrect parameters are specified for the schedule policy (policy) specified in the arguments,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to schedule policy and priority.\n
///        Error occur if the real-time schedule policy is set and
///        the priority is passed value outside the range of 1-99.\n
///        In the case of TSS, an error does not occur even if it is outside the range of -20 to 19,
///        but ti is rounded to the nearest integer by a system call when a process is created.\n
///        If not set by this funtion, the schedule policy set the TSS and priority sets 0.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetSchedule(CL_ProcessAttr_t *attr,  // NOLINT(readability/nolint)
                                    CL_ProcessSchedPolicy_t policy,
                                    int priority);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetGroup
/// \~english @par Brief
///        Set process attribute to process group
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] create
///        int   - (0 or 1)
/// \~english @par
///        - 1  make
///        - 0  not make(default)
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When a value oher than 0 or 1 is secified for the process group cration flag (create)
///          specified in the parameter, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to process group.\n
///        When a process group is created, all descendant process fork from child process also belong
///        to the same process group, and the entire process group can be forcibly terminated.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetGroup(CL_ProcessAttr_t *attr, int create);  // NOLINT(readability/nolint)

int CL_ProcessCreateAttrSetCpuAssign(CL_ProcessAttr_t *attr, int cpu_assign);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetStackSize
/// \~english @par Brief
///        Set process attribute to stack size
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] stack_size
///        int   - stack size(byte)
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to stack size.\n
///        The muximum configurable stack size is 1MB.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetStackSize(CL_ProcessAttr_t *attr, int stack_size);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetHoldFds
/// \~english @par Brief
///        Set process attribute to FD to maintain
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] hold_fds[]
///        int   -
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When the array (hode_openfd[]) storing the list of the FD to be maintained specified
///          by the arguments is NULL, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to FD to maintain.\n
///        When nothing is set, FD other than 0, 1, and 2 are automatically close.\n
///        For hold_openfds is stored in a CL_PROCESSS_ATTR_HOLD_FDS_NUM array,
///        it is recommended that int hold_openfds[CL_PROCESSS_ATTR_HOLD_FDS_NUM] be used.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetHoldFds(CL_ProcessAttr_t *attr, int hold_fds[]);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetDisableCloseFds
/// \~english @par Brief
///        Set process attribute to suspend forced FD close
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to suspend forced FD close.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetDisableCloseFds(CL_ProcessAttr_t *attr);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateAttrSetCgroup
/// \~english @par Brief
///        Set process attribute to Cgroup
/// \~english @param [in,out] attr
///        const CL_ProcessAttr_t* - Process attribute pointer
/// \~english @param [in] cgroup_name
///        const char*   - Cgroup name
/// \~english @par
///        CL_ProcessAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[148];
///                 } CL_ProcessAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateAttrInit.
///        - cgroup specified by CL_ProcessCreateCgroupCreate() has been created.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When the pointer (name) to the character string hat stores the process name specified
///          by the argument is NULL, set errno to EINVAL, -1 is returned.
///        - When the character string length of the character string (cgroup_name) storing the process name specified
///          by the argument is 64 byte or more, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Set process attribute to Cgroup.\n
///        Creat new Cgroup with CL_ProcessCreateCgroupCreate().\n
///        An error occurs if an Cgroup name that does not exist is specified.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateAttrSetCgroup(CL_ProcessAttr_t *attr,  // NOLINT(readability/nolint)
                                  const char *cgroup_name);

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessTerminate
/// \~english @par Brief
///        Kill the process
/// \~english @param [in] pid
///        pid_t - PID
/// \~english @retval int file  descriptor
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - CL_ProcessInit and CL_ProcessCreate must be running.
///          (Process ID to be forcibly terminated exists)
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the process ID to be forcibly terminated does not exist, -1 is returned.
/// \~english @par Detail
///        The PID of the process is he return value (PID) of CL_ProcessCreate().
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        CL_ProcessCreate
/////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessTerminate(pid_t pid);  // NOLINT(readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessTerminateGroup
/// \~english @par Brief
///        Kill process group
/// \~english @param [in] pid
///        pid_t - process group ID
/// \~english @retval int file descriptor
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - CL_ProcessInit and CL_ProcessCreate must be running.
///          (Process ID to be forcibly terminated exists)
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the process ID to be forcibly terminated does not exist, -1 is returned.
/// \~english @par Detail
///        The process group ID is he return value (PID) of CL_ProcessCreate().
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        CL_ProcessCreate
/////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessTerminateGroup(pid_t pid);  // NOLINT(readability/nolint)

int CL_ProcessAbort(pid_t pid);  // NOLINT(readability/nolint)

int CL_ProcessAbortGroup(pid_t pid);  // NOLINT(readability/nolint)

int CL_ProcessEuthanizeGroup(pid_t pid);  // NOLINT(readability/nolint)

/////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCleanup
/// \~english @par Brief
///        Collect child process
/// \~english @param [in] sigchld_fd
///        int - CL_ProcessInit() function return to fd
/// \~english @param [out] cleanup_info
///        CL_ProcessCleanupInfo_t* - Pointer to chiled process info
/// \~english @par
///        CL_ProcessCleanupInfo_t struct
/// \~english @code
///                 typedef struct {
///                   pid_t pid;                /* The process ID of the child. */
///                   int code;                 /* signal code */
///                   int status;               /* the exit status of the child or the signal */
///                 } CL_ProcessCleanupInfo_t;
///            @endcode
/// \~english @retval 0  Success
/// \~english @retval 1  Success
///        (If WNOHANG was specified and no child(ren) specified by id has yet changed state)
/// \~english @retval -1 Error (setting to errno)
/// \~english @par Prerequisite
///        - Must be runnning CL_ProcessInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer (cleanup_info) to the child process information structure is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When a systemu call (waitid) fails, -1 is returned.
///        - When there are no child process in state waitable, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        This API must be called before createing a thread.\n
/// \~english @par
///        It must be called many times while the return valu is 1.
///        After the return value reaches 0, calling it again results in an error (ECHILD).\n
///        The code of CL_ProcessCleanupInfo_t cotains the following value:\n
///          - CLD_EXITED : Finished child process (exited)
///          - CLD_KILLED : Killed child process
///          - CLD_DUMPED : Ended abnormally child process
///          - CLD_TRAPPED : Trapped traced child process
///          - CLD_STOPPED : Stopped child process (stop)
///          - CLD_CONTINUED restarted the sopped child process (after Linux 2.6.9)
///          - The exit status is stored in status only when code is CLD_EXITED. Otherwise, signals are stored.
///          - Need to include signal.h to use CLD_*.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCleanup(int sigchld_fd, CL_ProcessCleanupInfo_t *cleanup_info);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ThreadCreate
/// \~english @par Brief
///        Create thread
/// \~english @param [out] thread
///        pthread_t*   - thread hadle
/// \~english @param [in] attr
///        pthread_attr_t*   - Thread attibute pointer for pthread
/// \~english @param [in] cl_attr
///        CL_ThreadAttr_t*   - Tred attribute pointer for expansion
/// \~english @param [in] start_routine
///        void*(*)(void*)   - Pointer to the entry function of the thread
/// \~english @param [in] arg
///        void*   - Argument to the entry function of the thread
/// \~english @par
///        CL_ThreadAttr_t structure
/// \~english @code
///                 typedef struct {
///                   char body[20];
///                 } CL_ThreadAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error (set errno)
/// \~english @retval EAGAIN failure to create thread
/// \~english @par Prerequisite
///        - Prerequisites are nothing.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - When the thread handler (thread) specified in the argument is NULL, set errno to EINVAL, -1 is returned.
///       - When the pointer of the thread attribute specified in the argument is NULL,
///         set errno to EINVAL, -1 is returned.
///       - When the pointer (start_routine) of the entry function of the thread specified by the argument is NULL,
///         set errno to EINVAL, -1 is returned.
///       - Failure to initialize semaphore, set errno to sem_init, -1 is returned.
///       - Failure to create thread (pthread_create), EAGAIN is returned.
///       - Failure to rock semaphore (sem_wait), set errno to sem_init, -1 is returned.
/// \~english @par Detail
///        Create thread.\n
///        The extension thread attribute (cl_attr) is used o assign the thread name set
///        by CL_ThreadCreateAttrSetName(CL_ThreadAttr_t*, const char*).\n
/// \~english @par Classification
///        Public
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ThreadCreate(pthread_t *thread, pthread_attr_t *attr,  // NOLINT(readability/nolint)
                    CL_ThreadAttr_t *cl_attr, void *(*start_routine)(void *),
                    void *arg);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ThreadCreateAttrInit
/// \~english @par Brief
///        Initialize thread attribute
/// \~english @param [out] attr
///        CL_ThreadAttr_t*   - thread attribute pointer
/// \~english @par
///        CL_ThreadAttr_t structure
/// \~english @code
///                 typedef struct {
///                   char body[20];
///                 } CL_ThreadAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error (set errno)
/// \~english @par Prerequisite
///        - Prerequisites are nothing.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - When the pointer (attr) of the thread attributespecified by the argument is NULL, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///       Initialize structure CL_ThreadAttr_t that stores threade attribute.\n
/// \~english @par Classification
///        Public
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ThreadCreateAttrInit(CL_ThreadAttr_t *attr);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ThreadCreateAttrSetName
/// \~english @par Brief
///        Set thread attribute to thread name
/// \~english @param [out] attr
///        CL_ThreadAttr_t*   - thread attribute pointer
/// \~english @param [in] name
///        const char*   - Pointer to the string storing the thread name (max length 16byte)
/// \~english @par
///        CL_ThreadAttr_t structure
/// \~english @code
///                 typedef struct {
///                   char body[20];
///                 } CL_ThreadAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error (set errno)
/// \~english @par Prerequisite
///        - Prerequisites are nothing.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - When the pointer (attr) of thread attribute specified by the argument is NULL, set errno to EINVAL, -1 is returned.
///       - When the pointer (name) to the character string that stores the thread name specified
///         by the argument is NULL, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///       Set thread attribute to thread name\n
///       The characer string that stores the thread name specified by the argument must satisfy the following conditions:\n
///       - Terminated by a NULL.\n
///       - The maximum lengthof character string is 16 byte including the termination character.\n
/// \~english @par Classification
///        Public
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ThreadCreateAttrSetName(CL_ThreadAttr_t *attr, const char *name);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupCreate
/// \~english @par Brief
///        Create Cgroup
/// \~english @param [in] cgroup_name
///        const char* - cgroup name
/// \~english @param [in] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribut
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr by CL_ProcessCreateCgroupAttrInit
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - When the Cgroup name (cgroup_name) specified by the argument is NULL, set errno to EINVAL, -1 is returned.
///       - When the pointer (attr) of the Cgroup attribute specified by the argumet is NULL,
///         set errno to EINVAL, -1 is returned.
///       - When the area for directory path name of the CPU subsystem of Cgroup could not be allocated,
///         set errno to EINVAL, -1 is returned.
///       - When the area for directory of the CPU subsystem of Cgroup could not be create, -1 is returned.
///       - When the area for file path name of the CPU subsystem of Cgroup could not be allocated,
///         set errno to EINVAL, -1 is returned.
///       - When file descriptor of the CPU subsystem of Cgroup could not be acquired, -1 is returned.
///       - When setting value to CPU subsystem of Cgroup could not be written, -1 is returned.
///       - When the area for directory path name of the memory subsystem of Cgroup could not be allocated,
///         set errno to EINVAL, -1 is returned.
///       - When the area for directory of the memory subsystem of Cgroup could not be create, -1 is returned.
///       - When the area for file path name of the memory subsystem of Cgroup could not be allocated,
///         set errno to EINVAL, -1 is returned.
///       - When file descriptor of the memory subsystem of Cgroup could not be acquired, -1 is returned.
///       - When setting value to memory subsystem of Cgroup could not be written, -1 is returned.
/// \~english @par Detail
///        Create Cgroup to which the process to be created belongs.
///        If it belongs to Cgroup that has already been created, it is not necessary to create it.\n
/// \~english @par
///        Since the Cgroup attribute cannot be changed during Cgroup, if it is necessary o chage the Cgroup attribute,
///        it is necessary to call the following API and change the Cgroup attribute calling this API.\n
///          - CL_ProcessCreateCgroupAttrInit :Initialize Cgroup attribute
///          - CL_ProcessCreateCgroupAttrSetCfsBandwidthControl :TSS process CPU time control by Bandwidth Control
///          - CL_ProcessCreateCgroupAttrSetCpuShares :TSS process CPU time control
///          - CL_ProcessCreateCgroupAttrSetMemoryLimit :Contol memory usage
///          - CL_ProcessCreateCgroupAttrSetMemoryUsageNotification :Memory usage notification setting
///          - CL_ProcessCreateCgroupAttrSetRtThrottling :FIFO/RR process CPU time control
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        CL_ProcessCreateCgroupDelete,
///        CL_ProcessCreateCgroupAttrInit, CL_ProcessCreateCgroupAttrSetCfsBandwidthControl,
///        CL_ProcessCreateCgroupAttrSetCpuShares, CL_ProcessCreateCgroupAttrSetMemoryLimit,
///        CL_ProcessCreateCgroupAttrSetMemoryUsageNotification, CL_ProcessCreateCgroupAttrSetRtThrottling,
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupCreate(const char *cgroup_name,  // NOLINT(readability/nolint)
                                 CL_ProcessCreateCgroupAttr_t *attr);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttrInit
/// \~english @par Brief
///        Initialize Cgroup attribute
/// \~english @param [out] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Prerequisites are nothing.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - When the pointer of Cgroup attribute (attr) specified in the arguments is NULL, set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///       Initialize Cgroup attibute with 0.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupAttrInit(CL_ProcessCreateCgroupAttr_t *attr);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttrSetRtThrottling
/// \~english @par Brief
///        Set FIFO/RR process CPU time control
/// \~english @param [in,out] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute
/// \~english @param [in] runtime_us
///        int - CPU allocation time(us)
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateCgroupAttrInit.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of Cgroup attribute (attr) specified in the arguments is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Limiting the CPU time allocated to a process to
///        which a real-time class schedule policy (SCHED_FIFO/SCHED_RR) is applied.\n
///        Set the value of argument runtime_us to the cpu.rt_runtime_us (CPU allocation time) of created Cgroup.\n
///        cpu.rt_period_us(unit time:1000000us) is not changed.\n
///        If not set, Cgroup created will remain at default (CPU allocation time:950000us).\n
///        The configurable range of runtime_us depends on the use of Cgroup and the kernel version.
///        The user sets an appropriate value.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupAttrSetRtThrottling(  // NOLINT(readability/nolint)
    CL_ProcessCreateCgroupAttr_t *attr, int runtime_us);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttrSetCpuShares
/// \~english @par Brief
///        Set TSS process CPU time control
/// \~english @param [in,out] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
/// \~english @param [in] cpu_shares
///        int - An integer value that sepcified the relative distribution of CPU time
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateCgroupAttrInit
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer (attr) of the Cgroup attribute specified by the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Cotrols the CPU time allocated to a process to which
///        a class TSS schedule policy (SCHED_OTHER, etc.) is applied.\n
///        If cpu_shares is set with this function, a single Cgroup is created and cpu.shares is set with that value.\n
///        If not set, remain at default.\n
///        cpu_shares is set to the standard value 1024, and CPU time is allocated according
///        to the allocaion value specified between Cgroup.\n
///        Task Cgroup with cpu.shares set to 1024 has twice as much CPU time as
///        task Cgroup with cpu.shares set to 512.\n
///        Processes belonging to the same Cgroup are equally allocated CPU time allocated to Cgroup.\n
///        Note that the time distribution is distributed across al CPU cores on a multi-core system.\n
///        In a multicore system, if Cgroup limit is set to 100% of the CPU,
///        100% of each CPU core wil be available.\n\n
///        Examle) If Cgroup A is set to use 25% of the CPU and Cgroup B is set to use 75% of the CPU,\n
///        and a process that uses CPU intensively is started on a 4-core system (1 process in A and 3 processes in B),\n
///        the CPU allocaion is distributed as follows.\n\n
/// \~english @par
///        | PID | cgroup | CPU | CPU allotment |
///        |:---:|:------:|:---:|:-------:|
///        | 100 | A | 0 | CPU0 100% |
///        | 101 | B | 1 | CPU1 100% |
///        | 102 | B | 2 | CPU2 100% |
///        | 103 | B | 3 | CPU3 100% |
/// \~english @par
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupAttrSetCpuShares(CL_ProcessCreateCgroupAttr_t *attr,  // NOLINT(readability/nolint)
                                           int cpu_shares);

///////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttrSetCfsBandwidthControl
/// \~english @par Brief
///        Set TS process CU time control by Bandwidth Control
/// \~english @param [in,out] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
/// \~english @param [in] cfs_quota_us
///        int - CPU allocation time
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateCgroupAttrInit
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Controls the amount of time allocated to processes o whitch TSS class schedule plicy (SCHED_OTHER, etc.) are
///        applied using bandwidth control of CFS(Completely Fair Scheduler) implemented from kernel 3.2.\n
///        Set the value of argument cfs_quota_us to the cpu.cfs_quota_us of created Cgroup.\n
///        cpu.cfs_period_us(unit time:1000000us) is not changed.\n
///        If not set, the created Cgroup will not have CPU allocatio control. (set cpu.cfs_guota_us to -1).\n
///        The time (%) allocated to Cgroup can be set correctly,
///        and it can be allocated correctly if the CPU is free.\n
///        It is scheduled to be allocated as much as possible even if it conflicts with other Cgroup's.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupAttrSetCfsBandwidthControl(  // NOLINT(readability/nolint)
    CL_ProcessCreateCgroupAttr_t *attr, int cfs_quota_us);

/////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttrSetMemoryLimit
/// \~english @par Brief
///        Control memory usage
/// \~english @param [in,out] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
/// \~english @param [in] memory_limit
///        int - memory limit (byte)
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateCgroupAttrInit
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        Control the CPU time allocated to a process.\n
///        Set the value of argument memory_limit to the memory.limit_in_bytes of created Cgroup.\n
///        If not set, there is no memory limit.When a request exceeding the memory limit is issued,
///        a SIGKILL is sent from the kernel and the process is discarded.
///        Note: When the memory limit is exceeded, control moves to 00M,
///        but its operation ca be changed (Documentation/cgroup/memory.txt).\n
///        Write memory.oom_control to 1 to stop the OOM-Killer.
///        When OOM-Killer is stopped, the task below Cgroup becomes hang/sleep.\n
///        The task moves when the limit of the memory Cgroup increaes or when usage decreases. When usage decreases,\n
///        - Task was killed\n
///        - Task was moved other group\n
///        - File has been deleted\n
/// \~english @par
///       You can also receive a eventf notification from OOM.\n
///       Memory usage is counted as follows\n
///        - RSS(All mapped anon pages)\n
///        - Page Cache\n
///        - First acess Shared Pages in Cgroup\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupAttrSetMemoryLimit(CL_ProcessCreateCgroupAttr_t *attr,  // NOLINT(readability/nolint)
                                             int memory_limit);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupAttrSetMemoryUsageNotification
/// \~english @par Brief
///        Set notificatio when memory usage exceeds the specified amount
/// \~english @param [in,out] attr
///        const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
/// \~english @param [in] usage_in_bytes
///        int - usage in bytes(byte)
/// \~english @param [in] event_fd
///        int - File dexcriptor created by system call eventfd()
/// \~english @par
///        CL_ProcessCreateCgroupAttr_t struct
/// \~english @code
///                 typedef struct {
///                   char body[24];
///                 } CL_ProcessCreateCgroupAttr_t;
///            @endcode
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Initialize attr with CL_ProcessCreateCgroupAttrInit
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the pointer of the process attribute specified (attr) in the argument is NULL,
///          set errno to EINVAL, -1 is returned.
///        - When event_fd is negative for a file descriptor created by system call eventfd(),
///          set errno to EINVAL, -1 is returned.
/// \~english @par Detail
///        event_fd is notifued when memory usage exceeds argument usage_in_bytes.\n
///        See eventfd for details of event_fd.\n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupAttrSetMemoryUsageNotification(  // NOLINT(readability/nolint)
    CL_ProcessCreateCgroupAttr_t *attr, int usage_in_bytes, int event_fd);

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupDelete
/// \~english @par Brief
///        Delete Cgroup
/// \~english @param [in] cgroup_name
///        const char* - cgroup name
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Need to be runnning CL_ProcessCreateCgroupCreate.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the Cgroup (cgroup_name) name specified inthe argument is NULL, set errno to EINVAL, -1 is returned.
///        - When the area for directory path name of the CPU subsystem of Cgroup and
///          memory subsystem of Cgroup could not be allocated,  set errno to EINVAL, -1 is returned.
///        - When the area for the directory path name of the memory subsystem of Cgroup cannot be allocated and
///          the directory for the CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
///        - When the directory for the CPU subsystem of Cgroup does not exist and
///          the area for the directory path name of the memory subsystem of Cgroup cannot be allocated,
///          set errno to EINVAL, -1 is returned.
///        - When the directory for the memory subsystem of Cgroup and
///          the directory for the CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
///        - When the directory for the memory subsystem of Cgroup could not be deleted, -1 is returned.
///        - When the directory for the CPU subsystem of Cgroup could not be deleted, -1 is returned.
/// \~english @par Detail
///        Delete Cgroup. If there is a proess belonging to Cgroup, error code (EBUSY) is returned.\n
/// \~english @par
///        Success is also notified in the following cases:\n
///        - When the area for directory path name of memory subsyste Cgroup could not be allocated
///          but CPU subsystem of Cgroup was deleted successfully.
///        - When the directory for the memory subsystem of Cgroup does not exist,
///          but CPU subsystem of Cgroup was deleted successfully.
///        - When the area for directory path name of CPU subsyste Cgroup could not be allocated
///          but memory subsystem of Cgroup was deleted successfully.
///        - When the directory for the CPU subsystem of Cgroup does not exist,
///          but memory subsystem of Cgroup was deleted successfully.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        CL_ProcessCreateCgroupCreate
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupDelete(const char *cgroup_name);  // NOLINT(readability/nolint)

////////////////////////////////////////////////////////////////////////////////////
/// \ingroup CL_ProcessCreateCgroupClassify
/// \~english @par Brief
///        Move process to the Cgroup
/// \~english @param [in,out] cgroup_name
///        const char* - Destination A name
/// \~english @param [in] pid
///        pid_t - process ID
/// \~english @retval 0 Success
/// \~english @retval -1 Error
/// \~english @par Prerequisite
///        - Need to be running CL_ProcessCreateCgroupCreate.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - When the Cgroup (cgroup_name) specified in the argument is NULL, set errno to EINVAL, -1 is returned.
///        - When the area for directory path name of memory subsystem of Cgroup and
///          CPU subsystem of Cgroup could not be allocated, set errno to EINVAL, -1 is returned.
///        - When the area for directory path name of memory subsystem of Cgroup could not be allocated,
///          and the directory for CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
///        - When the directory for memory subsystem of Cgroup does not exist and
///          the directory for CU subsystem of Cgroup could not allocated , set errno to EINVAL, -1 is returned.
///        - When the directory for the memory subsystem of Cgroup and
///          the directory for the CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
///        - When the area for directory path name of the memory subsystem of Cgroup could not allocated,
///          set errno to EINVAL, -1 is returned.
///        - When the file descripter for the memory subsystem of Cgroup could not be obtained, -1 is returned.
///        - When pid could not be written to the file for memory subsystem of Cgroup, -1 is returned.
///        - When the area for directory path name of the CPU subsystem of Cgroup could not be allocated,
///          set errno to EINVAL, -1 is returned.
///        - When the file decsripter for the CPU subsystem of Cgroup could not be allocated, -1 is returned.
///        - When pid could not be written to the file for CPU subsystem of Cgroup, -1 is returned.
/// \~english @par Detail
///        Move process to the Cgroup.\n
/// \~english @par
///        Success is also notified in the following cases:\n
///        - When the area for directory path name of memory subsyste Cgroup could not be allocated
///          but CPU subsystem of Cgroup was deleted successfully.
///        - When the directory for the memory subsystem of Cgroup does not exist,
///          but CPU subsystem of Cgroup was deleted successfully.
///        - When the area for directory path name of CPU subsyste Cgroup could not be allocated
///          but memory subsystem of Cgroup was deleted successfully.
///        - When the directory for the CPU subsystem of Cgroup does not exist,
///          but memory subsystem of Cgroup was deleted successfully.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        none
////////////////////////////////////////////////////////////////////////////////////
int CL_ProcessCreateCgroupClassify(const char *cgroup_name, pid_t pid);  // NOLINT(readability/nolint)

/** @}*/  // end of common_library
/** @}*/  // end of NativeService
/** @}*/  // end of BaseSystem
#ifdef __cplusplus
}
#endif

#endif  // #ifndef _cl_process_h_  // NOLINT(build/header_guard)