Sponsored Content
Full Discussion: Signalsafe data structures
Top Forums Programming Signalsafe data structures Post 302582285 by DreamWarrior on Thursday 15th of December 2011 11:05:17 AM
Old 12-15-2011
As others said, you should be very wary of doing work in a signal handler. There is a short list of async-signal safe functions. If you're calling anything outside that list, there is already potential for breakage even disregarding that caused by potential data structure corruption.

I would do as recommended, restructure your code to capture the signal and relay it outside the signal handler to be handled by the main thread of execution. You can use, for example, a pipe to put a byte on signaling something has been caught; since write is safe you can call it.

Even the pthread_mutex_lock is async-signal unsafe. Outside of rolling your own async-signal safe locks using atomic variables, I can't suggest anything else. Not to mention that even if you properly protect the data structure, you're still limited in what you can do to it by the lack of safe functions you can call.
 

3 More Discussions You Might Find Interesting

1. Programming

Recommendations For Generic C Data Structures & Algorithms

Hi All, Rather than re-invent the wheel, I am trying to find a mature C library that provides generic support for lists, trees, etc. I understand C doesn't formally support "generics", but am aware of a few solutions like GLib and SGLib. Can anyone kindly recommend what they think is best?... (1 Reply)
Discussion started by: tristan12
1 Replies

2. Programming

shared memory - userdefined data structures

Hello, I wonder if I can write my userdefined data structures(ex: a list) to a shared memory segment? I know, the shm functions get (void*) parameter so I should be able to read and write a list into the shared memory. may someone inform and clarify me about that, please? (1 Reply)
Discussion started by: xyzt
1 Replies

3. Shell Programming and Scripting

Perl Data Structures

Here is what i need to do. @data #has all column wise data so say info for col 1 location for all rows would be in this array $array = \@data But i need to create a file which should contain these information in a format for all columns even if i have got no values from some of the index... (0 Replies)
Discussion started by: dinjo_jo
0 Replies
Tangram::Type::Array::Scalar(3pm)			User Contributed Perl Documentation			 Tangram::Type::Array::Scalar(3pm)

NAME
Tangram::Type/Array/Scalar - map Perl array of strings or numbers SYNOPSIS
use Tangram::Core; use Tangram::Type/Array/Scalar; # always $schema = Tangram::Schema->new( classes => { NaturalPerson => { fields => { flat_array => { interests => { table => 'NP_int', sql => 'VARCHAR(50)', }, lucky_numbers => 'int', # use defaults } DESCRIPTION
Maps references to a Perl array. The persistent fields are grouped in a hash under the "array" key in the field hash. The array may contain only 'simple' scalars like integers, strings or real numbers. It may not contain references. For arrays of objects, see Tangram::Type::Array::FromMany and Tangram::Type::Array::FromOne. Tangram uses a table to save the state of the collection. The table has three columns, which contain * the id of the container object * the position of the element in the array * the value of the element The field names are passed in a hash that associates a field name with a field descriptor. The field descriptor may be either a hash or a string. The hash uses the following fields: * type * table * sql Optional field "type" specifies the type of the elements. If the type is "string"Tangram quotes the values as they are passed to the data- base. Not specifying a "type" is exactly equivalent to specifying "string". Optional field "table" sets the name of the table that contains the elements. This defaults to 'C_F', where C is the class of the contain- ing object and F is the field name. Optional field "sql" specifies the type that deploy() (see Tangram::Deploy) should use for the column containing the elements. If this field is not present, the SQL type is derived from the "type" field: if "type" is "string" (or is absent) VARCHAR(255) is used; otherwise, the "type" field is interpreted as a SQL type. If the descriptor is a string, it is interpreted as the value of the "type" field and all the other fields take the default value. perl v5.8.8 2006-03-29 Tangram::Type::Array::Scalar(3pm)
All times are GMT -4. The time now is 03:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy