/* test attr init; set stack; get stack */ #include #include void* foo(void*){ pthread_t self = pthread_self(); pthread_attr_t self_attr; pthread_getattr_np(self, &self_attr); size_t size; int status = pthread_attr_getstacksize(&self_attr, &size); if (status != 0){ sout | "error return code"; exit(1); } sout | "stack size is " | size; return NULL; } int main() { pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 123456789); pthread_t thr; void* res; pthread_create(&thr, &attr, foo, (void*)0); pthread_join(thr, &res); pthread_attr_destroy(&attr); return 0; }