mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-10-29 05:40:25 -04:00 
			
		
		
		
	Open device nodes with close-on-exec flag
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									ef2d3cf747
								
							
						
					
					
						commit
						8264b2fd0a
					
				
					 1 changed files with 19 additions and 13 deletions
				
			
		|  | @ -230,22 +230,28 @@ extern snd_lib_error_handler_t snd_err_msg; | |||
| # define link_warning(symbol, msg) | ||||
| #endif | ||||
| 
 | ||||
| /* open with resmgr */ | ||||
| #ifdef SUPPORT_RESMGR | ||||
| static inline int snd_open_device(const char *filename, int fmode) | ||||
| { | ||||
| 	int fd = open(filename, fmode); | ||||
| 	if (fd >= 0) | ||||
| 		return fd; | ||||
| 	if (errno == EAGAIN || errno == EBUSY) | ||||
| 		return fd; | ||||
| 	if (! access(filename, F_OK)) | ||||
| 		return rsm_open_device(filename, fmode); | ||||
| 	return -1; | ||||
| } | ||||
| #else | ||||
| #define snd_open_device(filename, fmode) open(filename, fmode); | ||||
| 	int fd; | ||||
| 
 | ||||
| #ifdef O_CLOEXEC | ||||
| 	fmode |= O_CLOEXEC; | ||||
| #endif | ||||
| 	fd = open(filename, fmode); | ||||
| 
 | ||||
| /* open with resmgr */ | ||||
| #ifdef SUPPORT_RESMGR | ||||
| 	if (fd < 0) { | ||||
| 		if (errno == EAGAIN || errno == EBUSY) | ||||
| 			return fd; | ||||
| 		if (! access(filename, F_OK)) | ||||
| 			fd = rsm_open_device(filename, fmode); | ||||
| 	} | ||||
| #endif | ||||
| 	if (fd >= 0) | ||||
| 		fcntl(fd, F_SETFD, FD_CLOEXEC); | ||||
| 	return fd; | ||||
| } | ||||
| 
 | ||||
| /* make local functions really local */ | ||||
| #define snd_dlobj_cache_lookup \ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rémi Denis-Courmont
						Rémi Denis-Courmont