![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 2
Rep Power: 0
![]() |
segfault using sigaction with gnu history
i am writing a shell program with a history feature. i am reassigning sigint (ctrl-c) to print the history list. i am trying to use the gnu history library to manage the history, but it now segfaults on ctrl-c. here is the code:
setup signal handler; struct sigaction handler; sigfillset(&handler.sa_mask); handler.sa_handler = handle_SIGINT; sigaction(SIGINT, &handler, NULL); void handle_SIGINT(int signo)
{
printf("sig\n");
}add_history(*args); any help would be appreciated, if more info is needed, let me know. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
Well, if the problem goes away when you comment out a call to add_history(), a fairly strong possibility is that the call of add_history() is the cause of the problem ...... which would mean the problem has nothing to the signal handling (the signal handling works incorrectly as a side-effect of an error by add_history()).
You haven't really provided enough information, but my guess is that add_history() assumes something about "args" that you are not honouring in main(). |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2006
Posts: 2
Rep Power: 0
![]() |
thanks for the response.. i tracked down the problem...
the add_history function did not work well with the *args pointer.. it would complile and execute once fine, but segfault.. fixed by assigning *args contents to buffer var and passing this in to add_history. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|