How C program can determine in what shell it is being executed ? There are some clumsy ways to solve this problems (for example, analyze the output of ps) but I feel that there must be a more elegant way.