0

VLC is running. Got the PID from pgrep vlc.

I want now to pause it manually since I would like it to run "submerged" (right now from another tty but probably as a daemon)

I tried to simply do sudo "pause" > /usr/bin/vlc/ having got the path by doing sudo ls -l /proc/<PID>/exe.

The answer is, even running the sudo command, that the permission is denied.

For my surprise, if I enter root mode sudo bash and just type the same command, the answer is not that the permission is denied, but rather that the "text file is busy". I'd like to guess what text file. I thought that command (in that case) inputted data to the command input manually (apart from writing to a text file)

qaztype
  • 73
  • 13
  • 1
    `sudo "pause" > /usr/bin/vlc/` does not do what you think it does. It executes the command `pause` as root and *writes the output of the `pause` command* to the file `/usr/bin/vlc/` (which looks like a directory, in which case writing to it is not a good idea) *as the ‘normal user’*, since `sudo` applies to the command being run (`pause`) but not things like redirection (`>`). **Think about what it is you're trying to do before you overwrite an important file.** – Biffen Mar 26 '15 at 21:36

1 Answers1

1

This is probably what you want to do.

Write to /proc/pid of the program/fd/0. The fd subdirectory contains the descriptors of all the opened files and file descriptor 0 is the standard input (1 is stdout and 2 is stderr).

Example

Terminal 1:

[ciupicri@hermes ~]$ cat
Xxx

Terminal 2:

[ciupicri@hermes ~]$ pidof cat
7417
[ciupicri@hermes ~]$ echo xxx > /proc/7417/fd/0

Taken from another stack overflow answer