Hi, The pthread_attr_getstacksize() and pthread_attr_setstacksize() functions, respectively, shall get

and set the thread _*creation*_ stacksize attribute in the attr object.

What i need is current stack size of a running thread. My problem is that i have a thread with constantly growing stack ( i can see it via /proc/PID/smaps ). Thread uses some functions from a proprietary shared library. I need to know when the stack size of the mentioned thread reaches RLIMIT_STACK so i can safely restart that thread before it crashes.

10x
-Mike

Muli Ben-Yehuda wrote:
On Sun, Oct 07, 2007 at 10:46:46AM +0200, Nadav Har'El wrote:
On Sun, Oct 07, 2007, Muli Ben-Yehuda wrote about "Re: getting the current stack 
size of a given thread on linux":
pthread_attr_getstacksize(). See also pthread.h for various other
thread stack manipulation routines.
Muli, how do you get the pthread_attr_t object for the currect
thread?

If you don't mind only being portable to GNU systems:

pthread.h:

#ifdef __USE_GNU
/* Initialize thread attribute *ATTR with attributes corresponding to the
   already running thread TH.  It shall be called on unitialized ATTR
   and destroyed with pthread_attr_destroy when no longer needed.  */
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
#endif

Not sure what's the non-portable way of doing it.

Cheers,
Muli


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to