FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 01-12-2012, 12:47 PM
Dan McGee
 
Default Use fileno() in isatty() call

This was our only use of the function that had a hardcoded file
descriptor.

Signed-off-by: Dan McGee <dan@archlinux.org>
---
src/pacman/pacman.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 326664d..bce73d2 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -801,7 +801,7 @@ int main(int argc, char *argv[])
config = config_new();

/* disable progressbar if the output is redirected */
- if(!isatty(1)) {
+ if(!isatty(fileno(stdout))) {
config->noprogressbar = 1;
}

--
1.7.8.3
 
Old 01-12-2012, 12:54 PM
Jan Steffens
 
Default Use fileno() in isatty() call

On Thu, Jan 12, 2012 at 2:47 PM, Dan McGee <dan@archlinux.org> wrote:
> This was our only use of the function that had a hardcoded file
> descriptor.
>
> Signed-off-by: Dan McGee <dan@archlinux.org>
> ---
> *src/pacman/pacman.c | * *2 +-
> *1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
> index 326664d..bce73d2 100644
> --- a/src/pacman/pacman.c
> +++ b/src/pacman/pacman.c
> @@ -801,7 +801,7 @@ int main(int argc, char *argv[])
> * * * *config = config_new();
>
> * * * */* disable progressbar if the output is redirected */
> - * * * if(!isatty(1)) {
> + * * * if(!isatty(fileno(stdout))) {
> * * * * * * * *config->noprogressbar = 1;
> * * * *}
>
> --
> 1.7.8.3
>
>

unistd.h contains #define STDOUT_FILENO 1
Isn't that portable? see man 3p stdout
 
Old 01-12-2012, 01:08 PM
Dan McGee
 
Default Use fileno() in isatty() call

On Thu, Jan 12, 2012 at 7:54 AM, Jan Steffens <jan.steffens@gmail.com> wrote:
> On Thu, Jan 12, 2012 at 2:47 PM, Dan McGee <dan@archlinux.org> wrote:
>> This was our only use of the function that had a hardcoded file
>> descriptor.
>>
>> Signed-off-by: Dan McGee <dan@archlinux.org>
>> ---
>> *src/pacman/pacman.c | * *2 +-
>> *1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
>> index 326664d..bce73d2 100644
>> --- a/src/pacman/pacman.c
>> +++ b/src/pacman/pacman.c
>> @@ -801,7 +801,7 @@ int main(int argc, char *argv[])
>> * * * *config = config_new();
>>
>> * * * */* disable progressbar if the output is redirected */
>> - * * * if(!isatty(1)) {
>> + * * * if(!isatty(fileno(stdout))) {
>> * * * * * * * *config->noprogressbar = 1;
>> * * * *}
>>
>> --
>> 1.7.8.3
>>
>>
>
> unistd.h contains #define STDOUT_FILENO 1
> Isn't that portable? see *man 3p stdout

I will counter with `man 3 stdout`, namely the last bit.

On program startup, the integer file descriptors associated with the
streams stdin, stdout, and stderr are 0, 1, and 2, respectively. The
preprocessor symbols STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO are
defined with these values in <unistd.h>. (Applying freopen(3) to one
of these streams can change the file descriptor number associated with
the stream.)

-Dan
 

Thread Tools




All times are GMT. The time now is 04:17 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org