Print this page
3830 SIGQUEUE_MAX's limit of 32 is too low


2356 
2357 /*
2358  * Return true if the signal number is in range
2359  * and the signal code specifies signal queueing.
2360  */
2361 int
2362 sigwillqueue(int sig, int code)
2363 {
2364         if (sig >= 0 && sig < NSIG) {
2365                 switch (code) {
2366                 case SI_QUEUE:
2367                 case SI_TIMER:
2368                 case SI_ASYNCIO:
2369                 case SI_MESGQ:
2370                         return (1);
2371                 }
2372         }
2373         return (0);
2374 }
2375 
2376 #ifndef UCHAR_MAX
2377 #define UCHAR_MAX       255
2378 #endif
2379 
2380 /*
2381  * The entire pool (with maxcount entries) is pre-allocated at
2382  * the first sigqueue/signotify call.
2383  */
2384 sigqhdr_t *
2385 sigqhdralloc(size_t size, uint_t maxcount)
2386 {
2387         size_t i;
2388         sigqueue_t *sq, *next;
2389         sigqhdr_t *sqh;
2390 
2391         i = (maxcount * size) + sizeof (sigqhdr_t);
2392         ASSERT(maxcount <= UCHAR_MAX && i <= USHRT_MAX);
2393         sqh = kmem_alloc(i, KM_SLEEP);
2394         sqh->sqb_count = (uchar_t)maxcount;
2395         sqh->sqb_maxcount = (uchar_t)maxcount;
2396         sqh->sqb_size = (ushort_t)i;
2397         sqh->sqb_pexited = 0;
2398         sqh->sqb_sent = 0;
2399         sqh->sqb_free = sq = (sigqueue_t *)(sqh + 1);
2400         for (i = maxcount - 1; i != 0; i--) {
2401                 next = (sigqueue_t *)((uintptr_t)sq + size);
2402                 sq->sq_next = next;
2403                 sq = next;
2404         }
2405         sq->sq_next = NULL;
2406         cv_init(&sqh->sqb_cv, NULL, CV_DEFAULT, NULL);
2407         mutex_init(&sqh->sqb_lock, NULL, MUTEX_DEFAULT, NULL);
2408         return (sqh);
2409 }
2410 
2411 static void sigqrel(sigqueue_t *);
2412 
2413 /*
2414  * allocate a sigqueue/signotify structure from the per process
2415  * pre-allocated pool.
2416  */




2356 
2357 /*
2358  * Return true if the signal number is in range
2359  * and the signal code specifies signal queueing.
2360  */
2361 int
2362 sigwillqueue(int sig, int code)
2363 {
2364         if (sig >= 0 && sig < NSIG) {
2365                 switch (code) {
2366                 case SI_QUEUE:
2367                 case SI_TIMER:
2368                 case SI_ASYNCIO:
2369                 case SI_MESGQ:
2370                         return (1);
2371                 }
2372         }
2373         return (0);
2374 }
2375 
2376 #ifndef INT_MAX
2377 #define INT_MAX 2147483647
2378 #endif
2379 
2380 /*
2381  * The entire pool (with maxcount entries) is pre-allocated at
2382  * the first sigqueue/signotify call.
2383  */
2384 sigqhdr_t *
2385 sigqhdralloc(size_t size, uint_t maxcount)
2386 {
2387         size_t i;
2388         sigqueue_t *sq, *next;
2389         sigqhdr_t *sqh;
2390 
2391         i = (maxcount * size) + sizeof (sigqhdr_t);
2392         ASSERT(maxcount <= INT_MAX);
2393         sqh = kmem_alloc(i, KM_SLEEP);
2394         sqh->sqb_count = maxcount;
2395         sqh->sqb_maxcount = maxcount;
2396         sqh->sqb_size = i;
2397         sqh->sqb_pexited = 0;
2398         sqh->sqb_sent = 0;
2399         sqh->sqb_free = sq = (sigqueue_t *)(sqh + 1);
2400         for (i = maxcount - 1; i != 0; i--) {
2401                 next = (sigqueue_t *)((uintptr_t)sq + size);
2402                 sq->sq_next = next;
2403                 sq = next;
2404         }
2405         sq->sq_next = NULL;
2406         cv_init(&sqh->sqb_cv, NULL, CV_DEFAULT, NULL);
2407         mutex_init(&sqh->sqb_lock, NULL, MUTEX_DEFAULT, NULL);
2408         return (sqh);
2409 }
2410 
2411 static void sigqrel(sigqueue_t *);
2412 
2413 /*
2414  * allocate a sigqueue/signotify structure from the per process
2415  * pre-allocated pool.
2416  */