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