mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Improve reporting of error situations in find_other_exec().
This function suppressed any stderr output from the called program, which is unnecessary in the normal case and unhelpful in error cases. It also gave a rather opaque message along the lines of "fgets failure: Success" in case the called program failed to return anything on stdout. Since we've seen multiple reports of people not understanding what's wrong when pg_ctl reports this, improve the message. Back-patch to all active branches.
This commit is contained in:
		
							parent
							
								
									c9a2532c83
								
							
						
					
					
						commit
						9ae8ebe0b2
					
				| @ -322,7 +322,7 @@ find_other_exec(const char *argv0, const char *target, | |||||||
| 	if (validate_exec(retpath) != 0) | 	if (validate_exec(retpath) != 0) | ||||||
| 		return -1; | 		return -1; | ||||||
| 
 | 
 | ||||||
| 	snprintf(cmd, sizeof(cmd), "\"%s\" -V 2>%s", retpath, DEVNULL); | 	snprintf(cmd, sizeof(cmd), "\"%s\" -V", retpath); | ||||||
| 
 | 
 | ||||||
| 	if (!pipe_read_line(cmd, line, sizeof(line))) | 	if (!pipe_read_line(cmd, line, sizeof(line))) | ||||||
| 		return -1; | 		return -1; | ||||||
| @ -352,12 +352,20 @@ pipe_read_line(char *cmd, char *line, int maxsize) | |||||||
| 	fflush(stdout); | 	fflush(stdout); | ||||||
| 	fflush(stderr); | 	fflush(stderr); | ||||||
| 
 | 
 | ||||||
|  | 	errno = 0; | ||||||
| 	if ((pgver = popen(cmd, "r")) == NULL) | 	if ((pgver = popen(cmd, "r")) == NULL) | ||||||
|  | 	{ | ||||||
|  | 		perror("popen failure"); | ||||||
| 		return NULL; | 		return NULL; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|  | 	errno = 0; | ||||||
| 	if (fgets(line, maxsize, pgver) == NULL) | 	if (fgets(line, maxsize, pgver) == NULL) | ||||||
| 	{ | 	{ | ||||||
| 		perror("fgets failure"); | 		if (feof(pgver)) | ||||||
|  | 			fprintf(stderr, "no data was returned by command \"%s\"\n", cmd); | ||||||
|  | 		else | ||||||
|  | 			perror("fgets failure"); | ||||||
| 		pclose(pgver);			/* no error checking */ | 		pclose(pgver);			/* no error checking */ | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user