FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
wazuh/src/shared/pthreads_op.c at fuzzing · postech-compsec/wazuh · GitHub
postech-compsec
/
wazuh
Public
forked from
wazuh/wazuh
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
wazuh
/
src
/
shared
/
pthreads_op.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (58 loc) · 1.87 KB
Breadcrumbs
wazuh
/
src
/
shared
/
pthreads_op.c
Copy path
File metadata and controls
74 lines (58 loc) · 1.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/* Copyright (C) 2015, Wazuh Inc.
* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation
*/
#ifndef
WIN32
#include
"shared.h"
#include
<pthread.h>
#include
<sys/resource.h>
/* Create a new thread and give the argument passed to the function
* Returns 0 on success or -1 on error
*/
int
CreateThreadJoinable
(
pthread_t
*
lthread
,
void
*
(
*
function_pointer
)(
void
*
),
void
*
data
)
{
pthread_attr_t
attr
;
size_t
read_size
=
0
;
size_t
stacksize
=
0
;
int
ret
=
0
;
if
(
pthread_attr_init
(
&
attr
)) {
merror
(
THREAD_ERROR
" Cannot initialize attributes."
);
return
-1
;
}
read_size
=
1024
*
(
size_t
)
getDefine_Int
(
"wazuh"
,
"thread_stack_size"
,
2048
,
65536
);
/* Set the maximum stack limit to new threads */
if
(
pthread_attr_setstacksize
(
&
attr
,
read_size
)) {
merror
(
THREAD_ERROR
" Cannot set stack size to %d KB."
, (
int
)
read_size
);
return
-1
;
}
if
(
pthread_attr_getstacksize
(
&
attr
,
&
stacksize
)) {
merror
(
THREAD_ERROR
" Cannot confirm stack size setting."
);
return
-1
;
}
mdebug2
(
"Thread stack size set to: %d KiB"
, (
int
)
stacksize
/
1024
);
ret
=
pthread_create
(
lthread
,
&
attr
,
function_pointer
, (
void
*
)
data
);
if
(
ret
!=
0
) {
merror
(
THREAD_ERROR
" %s (%d)"
,
strerror
(
ret
),
ret
);
return
-1
;
}
pthread_attr_destroy
(
&
attr
);
return
(
0
);
}
int
CreateThread
(
void
*
(
*
function_pointer
)(
void
*
),
void
*
data
)
{
pthread_t
lthread
;
if
(
CreateThreadJoinable
(
&
lthread
,
function_pointer
,
data
)
<
0
) {
return
0
;
}
if
(
pthread_detach
(
lthread
)
!=
0
) {
merror
(
THREAD_ERROR
" Cannot detach thread."
);
return
0
;
}
return
1
;
}
#endif
/* !WIN32 */
Back
|
FazBrowse Home
|
New Git URL