- Timestamp:
- Jun 23, 2010 1:37:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp
r28800 r30392 5 5 6 6 /* 7 * Copyright (C) 2007 Oracle Corporation7 * Copyright (C) 2007-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 44 44 # if defined(RT_OS_LINUX) /** @todo check this on solaris+freebsd as well. */ 45 45 # include <sys/ioctl.h> 46 # endif 47 # if defined(RT_OS_SOLARIS) && !defined(VBOX_VBGLR3_XFREE86) 48 # define VBGL_DO_MASK_SIGNALS 49 # include <signal.h> 46 50 # endif 47 51 # include <errno.h> … … 289 293 290 294 295 /* 296 * Helper macros for blocking and restoring signals. 297 */ 298 #ifdef VBGL_DO_MASK_SIGNALS 299 # define BLOCK_SIGNALS(Prf) \ 300 int Prf##_rcSig; \ 301 sigset_t Prf##_SigSetOld; \ 302 do \ 303 { \ 304 sigset_t Prf##_SigSetNew; \ 305 sigfillset(& Prf##_SigSetNew); \ 306 sigdelset(& Prf##_SigSetNew, SIGTERM); \ 307 sigdelset(& Prf##_SigSetNew, SIGINT); \ 308 sigdelset(& Prf##_SigSetNew, SIGHUP); \ 309 sigdelset(& Prf##_SigSetNew, SIGABRT); \ 310 sigdelset(& Prf##_SigSetNew, SIGKILL); \ 311 Prf##_rcSig = pthread_sigmask(SIG_BLOCK, & Prf##_SigSetNew, & Prf##_SigSetOld); \ 312 } while (0) 313 314 # define RESTORE_SIGNALS(Prf) \ 315 do \ 316 { \ 317 if (Prf##_rcSig == 0) \ 318 { \ 319 int Prf##_err = errno; /* paranoia */ \ 320 pthread_sigmask(SIG_SETMASK, & Prf##_SigSetOld, NULL); \ 321 errno = Prf##_err; \ 322 } \ 323 } while (0) 324 325 #else 326 # define BLOCK_SIGNALS(Prf) do { } while (0) 327 # define RESTORE_SIGNALS(Prf) do { } while (0) 328 #endif 329 330 291 331 /** 292 332 * Internal wrapper around various OS specific ioctl implemenations. … … 345 385 * header with an error code return field (much better alternative 346 386 * actually). */ 387 BLOCK_SIGNALS(SigPrefix); 347 388 int rc = ioctl((int)g_File, iFunction, &Hdr); 389 RESTORE_SIGNALS(SigPrefix); 348 390 if (rc == -1) 349 391 { … … 354 396 355 397 #elif defined(RT_OS_LINUX) 398 BLOCK_SIGNALS(SigPrefix); 356 399 # ifdef VBOX_VBGLR3_XFREE86 357 400 int rc = xf86ioctl((int)g_File, iFunction, pvData); … … 359 402 int rc = ioctl((int)g_File, iFunction, pvData); 360 403 # endif 404 RESTORE_SIGNALS(SigPrefix); 361 405 if (RT_LIKELY(rc == 0)) 362 406 return VINF_SUCCESS; … … 377 421 /* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */ 378 422 /** @todo test status code passing! */ 423 BLOCK_SIGNALS(SigPrefix); 379 424 int rc = xf86ioctl(g_File, iFunction, pvData); 425 RESTORE_SIGNALS(SigPrefix); 380 426 if (rc == -1) 381 427 return VERR_FILE_IO_ERROR; /* This is purely legacy stuff, it has to work and no more. */ … … 385 431 /* Default implementation - PORTME: Do not use this without testings that passing errors works! */ 386 432 /** @todo test status code passing! */ 433 BLOCK_SIGNALS(SigPrefix); 387 434 int rc2 = VERR_INTERNAL_ERROR; 388 435 int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2); 436 RESTORE_SIGNALS(SigPrefix); 389 437 if (RT_SUCCESS(rc)) 390 438 rc = rc2;
Note:
See TracChangeset
for help on using the changeset viewer.