All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] problem with rt_task_delete/pthread_cancel
@ 2008-04-14  3:33 Tomas Kalibera
  0 siblings, 0 replies; only message in thread
From: Tomas Kalibera @ 2008-04-14  3:33 UTC (permalink / raw
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 542 bytes --]

Hi,

I'm trying to terminate a program from a child task. The idea is that a 
joinable child task kills itself, unblocking its parent which exits the 
application. However, the program crashes when the child calls 
rt_task_delete.

Inspecting the core file by gdb shows this:

Program terminated with signal 11, Segmentation fault.
#0  0xb7f014cd in pthread_cancel () from /lib/tls/i686/cmov/libpthread.so.0

A simple program which triggers the problem is attached. Is this a bug, 
or the API should not be used in this way ?

Thanks,

Tomas

[-- Attachment #2: e.c --]
[-- Type: text/x-csrc, Size: 766 bytes --]


#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>

#include <native/task.h>
#include <rtdk.h>

RT_TASK child;

void child_body(void *cookie) {
  int rc;
  
  fprintf(stderr,"In child..\n");

  rc=rt_task_delete(rt_task_self());
  if (rc!=0) {
    fprintf(stderr,"rt_task_delete returned %d\n");
  }

}

int main(int argc, char **argv) {

  int rc;
  
  mlockall(MCL_CURRENT|MCL_FUTURE);
  
  rc=rt_task_create(&child,"ovmtask",0,11,T_JOINABLE);  
  if (rc!=0) {
    fprintf(stderr,"rt_task_create returned %d\n");
  }  

  rc=rt_task_start(&child,&child_body,NULL);
  if (rc!=0) {
    fprintf(stderr,"rt_task_start returned %d\n");
  }  

  rc=rt_task_join(&child);
  if (rc!=0) {
    fprintf(stderr,"rt_task_join returned %d\n");
  }  
  
  return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-14  3:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-14  3:33 [Xenomai-help] problem with rt_task_delete/pthread_cancel Tomas Kalibera

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.