2

I use gssproxy under Arch Linux, in particular

Name            : gssproxy
Version         : 0.8.0-1

I encountered the following behavior: When trying to pipe the output of /usr/bin/gssproxy like so

/usr/bin/gssproxy | cat

it blocks. However, when I just run this command: /usr/bin/gssproxy it does not block, but creates another process in the background

root 13720 0.0 0.0 59732 584 ? Ssl 11:44 0:00 /usr/bin/gssproxy

and exists.

I acknowledge that there is probably no point in piping the output of gssproxy, but nevertheless I am still wondering why this behavior occurs? In particular, what causes cat to block?

EDIT:

By blocking, I mean that the following command:

timeout -k 1 1 /usr/bin/gssproxy | cat,

does not terminate, while

timeout -k 1 1 /usr/bin/gssproxy

terminates immediately. Both command spawn gssproxy process in the background. I am wondering why the first command does not terminate after 1 second as I would expect?

  • 1
    How do you see that it's blocked? gssproxy is a daemon program. I would not be surprised if it simple tests to see whether it's standard output is connected to a terminal or not, and if it's not it may simply decide to not output anything (because it thinks it's running as it should be running, in the background). If it's connected to a terminal, it obviously re-executes itself in the background. – Kusalananda Apr 6 at 12:33
  • It might be similar to this: setsid sleep 5 doesn't block (and forks sleep), setsid sleep 5 | cat blocks for the duration of sleep. – A.B Apr 6 at 16:49
  • I observed the following situation: [root@d48293f221d9]# timeout -k 1 1 /usr/bin/gssproxy | cat ^C [root@d48293f221d9]# ps aux | grep gssproxy root 24131 0.0 0.0 59732 588 ? Ssl 07:44 0:00 /usr/bin/gssproxy where timeout does not cause a termination after 1 second, as I would expect. Would you have any idea why? – MLStudent Apr 7 at 7:45
0

As @Kusalananda, mentions gssproxy runs as a daemon, the parent process probably wait's untill it's child exits.

Here's a short shell script which emulates the same situation.

$ cat t1
#!/bin/bash
sleep 10 &

$ date; ./t1 | cat ; date
Sun Apr  7 10:59:02 BST 2019
Sun Apr  7 10:59:12 BST 2019

The date commands are there purely to show that after the subprocess exists (10 seconds) cat terminates

  • Thanks! But why is it that timeout -k 1 1 /usr/bin/gssproxy | cat does not cause the gssproxy process to exit? – MLStudent Apr 7 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.