mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse-server: Use fprintf to write the pid file
This simplifies the code and also avoids a warning with _FORTIFY_SOURCE:
    ../pipewire/src/modules/module-protocol-pulse/pulse-server.c: In function ‘create_pid_file’:
    ../pipewire/src/modules/module-protocol-pulse/pulse-server.c:6028:2: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
     6028 |  write(fd, pid_str, strlen(pid_str) + 1);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			
			
This commit is contained in:
		
							parent
							
								
									ac9bcdee31
								
							
						
					
					
						commit
						c6aa48548e
					
				
					 1 changed files with 5 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -6010,7 +6010,7 @@ error:
 | 
			
		|||
static int create_pid_file(void) {
 | 
			
		||||
	int res;
 | 
			
		||||
	char pid_file[PATH_MAX];
 | 
			
		||||
	char pid_str[32];
 | 
			
		||||
	FILE *f;
 | 
			
		||||
 | 
			
		||||
	if ((res = get_runtime_dir(pid_file, sizeof(pid_file), "pulse")) < 0) {
 | 
			
		||||
		return res;
 | 
			
		||||
| 
						 | 
				
			
			@ -6021,16 +6021,14 @@ static int create_pid_file(void) {
 | 
			
		|||
	}
 | 
			
		||||
	strcat(pid_file, "/pid");
 | 
			
		||||
 | 
			
		||||
	snprintf(pid_str, sizeof(pid_str), "%lu\n", (unsigned long)getpid());
 | 
			
		||||
 | 
			
		||||
	int fd = open(pid_file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
 | 
			
		||||
	if (fd < 0) {
 | 
			
		||||
	if ((f = fopen(pid_file, "w")) == NULL) {
 | 
			
		||||
		res = -errno;
 | 
			
		||||
		pw_log_error(NAME" failed to open pid file");
 | 
			
		||||
		return res;
 | 
			
		||||
	}
 | 
			
		||||
	write(fd, pid_str, strlen(pid_str) + 1);
 | 
			
		||||
	close(fd);
 | 
			
		||||
 | 
			
		||||
	fprintf(f, "%lu\n", (unsigned long)getpid());
 | 
			
		||||
	fclose(f);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue