1/* 2 * Copyright (c) 2002-3, Intel Corporation. All rights reserved. 3 * Created by: salwan.searty REMOVE-THIS AT intel DOT com 4 * This file is licensed under the GPL license. For the full content 5 * of this license, see the COPYING file at the top level of this 6 * source tree. 7 * 8 * Test that the pthread_kill() function shall return ESRCH when no 9 * thread could be found corresponding to that specified by the given 10 * thread ID. 11 * 12 * NOTE: Cannot find 6-1.c in PTS cvs. So write this one. 13 */ 14 15#include <pthread.h> 16#include <signal.h> 17#include <stdio.h> 18#include <stdlib.h> 19#include <unistd.h> 20#include <errno.h> 21#include <string.h> 22#include "posixtest.h" 23 24void * thread_function(void *arg) 25{ 26 /* Does nothing */ 27 pthread_exit((void*)0); 28 29 /* To please some compilers */ 30 return NULL; 31} 32 33int main() 34{ 35 pthread_t child_thread; 36 pthread_t invalid_tid; 37 38 int rc; 39 40 rc = pthread_create(&child_thread, NULL, 41 thread_function, NULL); 42 if (rc != 0) 43 { 44 printf("Error at pthread_create()\n"); 45 return PTS_UNRESOLVED; 46 } 47 48 rc = pthread_join(child_thread, NULL); 49 if (rc != 0) 50 { 51 printf("Error at pthread_join()\n"); 52 return PTS_UNRESOLVED; 53 } 54 55 /* Now the child_thread exited, it is an invalid tid */ 56 memcpy(&invalid_tid, &child_thread, 57 sizeof(pthread_t)); 58 59 if (pthread_kill(invalid_tid, 0) == ESRCH) { 60 printf("pthread_kill() returns ESRCH.\n"); 61 return PTS_PASS; 62 } 63 64 printf("Test Fail\n"); 65 return PTS_FAIL; 66} 67 68