EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Proglem doing CA calls after catching a signal
From: Robert Soliday <[email protected]>
To: Chris Timossi <[email protected]>, tech-talk <[email protected]>
Date: Tue, 20 Jul 2004 14:14:58 -0500
Thanks, this solved my problem.

--Bob

Chris Timossi wrote:
Robert,
I believe that you should replace ca_task_initialize with
> ca_context_create(ca_enable_preemptive_callback) in main. Then in the
> interrupt handler, you can call ca_current_context() to get the
> current context and finally join that context with
> ca_attach_context().

Chris Timossi


Robert Soliday wrote:

After upgrading to Epics/Base 3.14.6 from 3.13.10 I am having difficulty handling signals. In one of our applications if the user does a control-C it is suppose to trap the signal and restore the PVs to their original values. Odds are the control-c will occur while in a ca_pend_event call. When I go to do a ca_pend_io in the interrupt handler I get the error:

pthread_mutex_unlock failed: error Not owner
fatal error: epicsMutexOsdUnlock

I have included a simple program that displays the same problem. If anyone knows the proper way of doing CA calls after catching a signal please let me know.

Thanks,
--Bob Soliday



#include <stdio.h>
#include <strings.h>
#include <cadef.h>
#include <signal.h>

void interrupt_handler(int);

chid channelID[1];
char names[1][40];

int main(int argc, char **argv)
{
  strcpy(names[0], "oag:H1:setCurrentC");

  ca_task_initialize();
  if (ca_search(names[0], &channelID[0])!=ECA_NORMAL) {
    fprintf(stderr, "error: search failed for PV\n");
    return(1);
  }
  if (ca_pend_io(10)!=ECA_NORMAL) {
    fprintf(stderr, "error: search failed for PV\n");
    return(1);
  }
  fprintf(stdout, "Found PV\n");
  signal(SIGINT, interrupt_handler);
  ca_pend_event(10);
  ca_task_exit();
  fprintf(stdout, "Done\n");
  return(0);
}

void interrupt_handler(int sig) {
  double value;
  fprintf(stdout, "Interrupt detected\n");
  if (ca_get(DBR_DOUBLE, channelID[0], &value)!=ECA_NORMAL) {
    fprintf(stderr, "Error: unable to get value for PV\n");
  }
  if (ca_pend_io(10)!=ECA_NORMAL) {
    fprintf(stderr, "Error: unable to get value for PV\n");
  }
  fprintf(stdout, "value = %lf\n", value);
}





Replies:
Re: Proglem doing CA calls after catching a signal Eric Norum
References:
Proglem doing CA calls after catching a signal Robert Soliday

Navigate by Date:
Prev: Re: Proglem doing CA calls after catching a signal Eric Norum
Next: Re: Proglem doing CA calls after catching a signal Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Program calling CA from witrin a posix signal handler Jeff Hill
Next: Re: Proglem doing CA calls after catching a signal Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·