@@ -509,24 +509,27 @@ inline file_handle_t file_handle_from_mapping_handle(mapping_handle_t hnd)
509509inline bool create_directory (const char *path)
510510{
511511 ::mode_t m = ::mode_t (0777 );
512- return ::mkdir (path, m) == 0 ;
512+ int r = BOOST_INTERPROCESS_EINTR_RETRY (int , -1 , ::mkdir (path, m));
513+ return r == 0 ;
513514}
514515
515516inline bool open_or_create_directory (const char *path)
516517{
517518 ::mode_t m = ::mode_t (0777 );
518- return ::mkdir (path, m) == 0 || (errno == EEXIST);
519+ int r = BOOST_INTERPROCESS_EINTR_RETRY (int , -1 , ::mkdir (path, m));
520+ return r == 0 || (errno == EEXIST);
519521}
520522
521523inline bool open_or_create_shared_directory (const char *path)
522524{
523525 const ::mode_t m = ::mode_t (01777 );
524- const bool created = ::mkdir (path, m) == 0 ;
526+ int rc = BOOST_INTERPROCESS_EINTR_RETRY (int , -1 , ::mkdir (path, m));
527+ const bool created = rc == 0 ;
525528 const bool created_or_exists = created || (errno == EEXIST);
526529 // Try to maximize the chance that the sticky bit is set in shared dirs
527530 // created with old versions that did not set it (for security reasons)
528- const bool chmoded = ::chmod (path, m) == 0 ;
529- return created ? chmoded : created_or_exists;
531+ rc = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::chmod (path, m)) ;
532+ return created ? (rc == 0 ) : created_or_exists;
530533}
531534
532535inline bool remove_directory (const char *path)
@@ -547,9 +550,10 @@ inline file_handle_t create_new_file
547550 (const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false )
548551{
549552 (void )temporary;
550- int ret = ::open (name, ((int )mode) | O_EXCL | O_CREAT, perm.get_permissions ());
553+ int ret = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::open (name, ((int )mode) | O_EXCL | O_CREAT, perm.get_permissions () ));
551554 if (ret >= 0 ){
552- ::fchmod (ret, perm.get_permissions());
555+ int rc = BOOST_INTERPROCESS_EINTR_RETRY (int , -1 , ::fchmod (ret, perm.get_permissions ()));
556+ (void )rc;
553557 }
554558 return ret;
555559}
@@ -562,13 +566,14 @@ inline file_handle_t create_or_open_file
562566 // We need a loop to change permissions correctly using fchmod, since
563567 // with "O_CREAT only" ::open we don't know if we've created or opened the file.
564568 while (true ){
565- ret = ::open (name, ((int )mode) | O_EXCL | O_CREAT, perm.get_permissions ());
569+ ret = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::open (name, ((int )mode) | O_EXCL | O_CREAT, perm.get_permissions () ));
566570 if (ret >= 0 ){
567- ::fchmod (ret, perm.get_permissions());
571+ int rc = BOOST_INTERPROCESS_EINTR_RETRY (int , -1 , ::fchmod (ret, perm.get_permissions ()));
572+ (void )rc;
568573 break ;
569574 }
570575 else if (errno == EEXIST){
571- if ((ret = ::open (name, (int )mode)) >= 0 || errno != ENOENT){
576+ if ((ret = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::open (name, (int )mode) )) >= 0 || errno != ENOENT){
572577 break ;
573578 }
574579 }
@@ -583,11 +588,11 @@ inline file_handle_t open_existing_file
583588 (const char *name, mode_t mode, bool temporary = false )
584589{
585590 (void )temporary;
586- return ::open (name, (int )mode);
591+ return BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::open (name, (int )mode) );
587592}
588593
589594inline bool delete_file (const char *name)
590- { return ::unlink (name) == 0 ; }
595+ { return BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::unlink (name) ) == 0 ; }
591596
592597inline bool truncate_file (file_handle_t hnd, std::size_t size)
593598{
@@ -597,30 +602,30 @@ inline bool truncate_file (file_handle_t hnd, std::size_t size)
597602 errno = EINVAL;
598603 return false ;
599604 }
600- return 0 == ::ftruncate (hnd, off_t (size));
605+ return 0 == BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::ftruncate (hnd, off_t (size) ));
601606}
602607
603608inline bool get_file_size (file_handle_t hnd, offset_t &size)
604609{
605610 struct stat data;
606- bool ret = 0 == ::fstat (hnd, &data);
611+ bool ret = 0 == BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::fstat (hnd, &data) );
607612 if (ret){
608613 size = data.st_size ;
609614 }
610615 return ret;
611616}
612617
613618inline bool set_file_pointer (file_handle_t hnd, offset_t off, file_pos_t pos)
614- { return ((off_t )(-1 )) != ::lseek (hnd, off, (int )pos); }
619+ { return ((off_t )(-1 )) != BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::lseek (hnd, off, (int )pos) ); }
615620
616621inline bool get_file_pointer (file_handle_t hnd, offset_t &off)
617622{
618- off = ::lseek (hnd, 0 , SEEK_CUR);
623+ off = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::lseek (hnd, 0 , SEEK_CUR) );
619624 return off != ((off_t )-1 );
620625}
621626
622627inline bool write_file (file_handle_t hnd, const void *data, std::size_t numdata)
623- { return (ssize_t (numdata)) == ::write (hnd, data, numdata); }
628+ { return (ssize_t (numdata)) == BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::write (hnd, data, numdata) ); }
624629
625630inline file_handle_t invalid_file ()
626631{ return -1 ; }
@@ -635,7 +640,7 @@ inline bool acquire_file_lock(file_handle_t hnd)
635640 lock.l_whence = SEEK_SET;
636641 lock.l_start = 0 ;
637642 lock.l_len = 0 ;
638- return -1 != ::fcntl (hnd, F_SETLKW, &lock);
643+ return -1 != BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::fcntl (hnd, F_SETLKW, &lock) );
639644}
640645
641646inline bool try_acquire_file_lock (file_handle_t hnd, bool &acquired)
@@ -645,7 +650,7 @@ inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired)
645650 lock.l_whence = SEEK_SET;
646651 lock.l_start = 0 ;
647652 lock.l_len = 0 ;
648- int ret = ::fcntl (hnd, F_SETLK, &lock);
653+ int ret = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::fcntl (hnd, F_SETLK, &lock) );
649654 if (ret == -1 ){
650655 return (errno == EAGAIN || errno == EACCES) ?
651656 (acquired = false , true ) : false ;
@@ -660,7 +665,7 @@ inline bool release_file_lock(file_handle_t hnd)
660665 lock.l_whence = SEEK_SET;
661666 lock.l_start = 0 ;
662667 lock.l_len = 0 ;
663- return -1 != ::fcntl (hnd, F_SETLK, &lock);
668+ return -1 != BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::fcntl (hnd, F_SETLK, &lock) );
664669}
665670
666671inline bool acquire_file_lock_sharable (file_handle_t hnd)
@@ -670,7 +675,7 @@ inline bool acquire_file_lock_sharable(file_handle_t hnd)
670675 lock.l_whence = SEEK_SET;
671676 lock.l_start = 0 ;
672677 lock.l_len = 0 ;
673- return -1 != ::fcntl (hnd, F_SETLKW, &lock);
678+ return -1 != BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::fcntl (hnd, F_SETLKW, &lock) );
674679}
675680
676681inline bool try_acquire_file_lock_sharable (file_handle_t hnd, bool &acquired)
@@ -680,7 +685,7 @@ inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
680685 lock.l_whence = SEEK_SET;
681686 lock.l_start = 0 ;
682687 lock.l_len = 0 ;
683- int ret = ::fcntl (hnd, F_SETLK, &lock);
688+ int ret = BOOST_INTERPROCESS_EINTR_RETRY ( int , - 1 , ::fcntl (hnd, F_SETLK, &lock) );
684689 if (ret == -1 ){
685690 return (errno == EAGAIN || errno == EACCES) ?
686691 (acquired = false , true ) : false ;
@@ -693,30 +698,30 @@ inline bool release_file_lock_sharable(file_handle_t hnd)
693698
694699#if 0
695700inline bool acquire_file_lock(file_handle_t hnd)
696- { return 0 == ::flock(hnd, LOCK_EX); }
701+ { return 0 == BOOST_INTERPROCESS_EINTR_RETRY(int, -1, ::flock(hnd, LOCK_EX) ); }
697702
698703inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired)
699704{
700- int ret = ::flock(hnd, LOCK_EX | LOCK_NB);
705+ int ret = BOOST_INTERPROCESS_EINTR_RETRY(int, -1, ::flock(hnd, LOCK_EX | LOCK_NB) );
701706 acquired = ret == 0;
702707 return (acquired || errno == EWOULDBLOCK);
703708}
704709
705710inline bool release_file_lock(file_handle_t hnd)
706- { return 0 == ::flock(hnd, LOCK_UN); }
711+ { return 0 == BOOST_INTERPROCESS_EINTR_RETRY(int, -1, ::flock(hnd, LOCK_UN) ); }
707712
708713inline bool acquire_file_lock_sharable(file_handle_t hnd)
709- { return 0 == ::flock(hnd, LOCK_SH); }
714+ { return 0 == BOOST_INTERPROCESS_EINTR_RETRY(int, -1, ::flock(hnd, LOCK_SH) ); }
710715
711716inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
712717{
713- int ret = ::flock(hnd, LOCK_SH | LOCK_NB);
718+ int ret = BOOST_INTERPROCESS_EINTR_RETRY(int, -1, ::flock(hnd, LOCK_SH | LOCK_NB) );
714719 acquired = ret == 0;
715720 return (acquired || errno == EWOULDBLOCK);
716721}
717722
718723inline bool release_file_lock_sharable(file_handle_t hnd)
719- { return 0 == ::flock(hnd, LOCK_UN); }
724+ { return 0 == BOOST_INTERPROCESS_EINTR_RETRY(int, -1, ::flock(hnd, LOCK_UN) ); }
720725#endif
721726
722727inline bool delete_subdirectories_recursive
0 commit comments