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