new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / shared / pthreads_op.c
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All rights reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #ifndef WIN32
11 #include "shared.h"
12 #include <pthread.h>
13
14
15 /* Create a new thread and give the argument passed to the function
16  * Returns 0 on success or -1 on error
17  */
18 int CreateThread(void *function_pointer(void *data), void *data)
19 {
20     pthread_t lthread;
21     int ret = 0;
22
23     ret = pthread_create(&lthread, NULL, function_pointer, (void *)data);
24     if (ret != 0) {
25         merror(THREAD_ERROR, __local_name);
26         return (-1);
27     }
28
29     if (pthread_detach(lthread) != 0) {
30         merror(THREAD_ERROR, __local_name);
31         return (-1);
32     }
33
34     return (0);
35 }
36
37 #endif /* !WIN32 */
38