Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
When I first learned Linux, I was told almost everything in Linux is file. This morning, when I repeated it to my girlfriend. She asked what is not? I tried to find an example for half a day.
So my question is what is not file in Linux?
Almost. Almost everything in Posix is handled through a file descriptor. This means that the same functions used for file operations also apply for pipes, sockets, and hardware devices. This also means that if you use select (or one of its better alternatives), you can have one point in your program where you wait for all possible inputs.
With that said, some things in Posix, and in particular, in Linux, are definitely not files.
The most obvious ones are signals. They are handled asynchronously to the program's execution, and therefor cannot take on a file interface. For that purpose, pselect and one of its better alternatives were invented.
Things more subtly not files are thread synchronization constructs (mutexs, semaphores, etc.). Some attempt have been made to make those available as file descriptors as well (see signalfd and eventfd), but those hardly caught on. I believe that this is due, in large part, for them having a vastly different performance profiles than the ususal way of handling them.
for example computer hardware (CPU, RAM, Etc) is not actually a file, but it is represented as a file in linux.
More details here
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I need to send data to a Linux terminal, in this manner that terminal could receive the data with scanf? there is any way to do that?
I tried to write my desired data to /proc/pid/fd/1 with below command, however, I can see the written data in the terminal but scanf couldn't catch that data and still wait for the user to enter data.
printf "85\n" > /proc/24737/fd/1
This is a very interesting question, and there is no easy way (that I know of) to write to a another terminal using the file descriptors.
see https://unix.stackexchange.com/questions/385771/writing-to-stdin-of-a-process
However, Unix and Linux, have many great ways for IPC (inter process communication). You might want to looking into pipes, named pipes, or Sockets.
Depending on what you are doing you might think about popen, or screen.
You probably don't want to write to the terminal, but the task that is running on the terminal? Can you change how the task is invoked (called)? Do you need to use standard in for other things?
If you explain your use case, we will try to direct you better.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I read, some years ago, that you could get linux to invoke the java command to run java programs by adding a bit of linux magic, but I can't remember how to do it or where I read it.
Back then I got it working and, if I recall correctly, it was fairly easy to do; just tell linux to use java to run .jar or similar files. I believe I also got it to run powerpc binaries, through qemu, using the same technique. Naturally, you would still have to mark them as exeutable.
I am not talking running java java_program_to_run or using some shell script that will, essentially, just call the same command. Nor am I asking for a way to convert a java program to an x86 binary for any particular operating system.
It was a technique that would allow Linux to deal with exectuables that wheren't native to the system, almost, as if they where native (some simulation required).
You want to checkout binfmt. More specifically, follow the instructions for java. I realize the usual practice is to copy the details into the answer, but they're quite long and it doesn't feel right to copy-and-paste the whole thing into the answer.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I am reading a chapter Sytem Protection of operating system of Peter Baer Galvin.
Inside the chapter there is a paragraph inside a subtopic Principles of Protection which I m not able to understand .
An operating system following the principles of least privilege
implements its features, programs ,system calls, and data structures
so that failure or compromise of a component does the minimum damage
and allows the minimum damage to be done. The overflow of a buffer in
a system daemon might cause the daemon to fail, for example ,but
should not allow the execution of code from the process's stack that
would enable a remote user to gain maximum privileges and access to
the entire system (as happens too often today).
Please help me to understand this pragraph.
Basically, the developers of a hardened (inherently relatively secure) OS should follow common sense and give a non-kernel process the absolute minimal amount of access it needs to do its job. If you don't do this, then anything executing at kernel privilege level can potentially crash the system or, worse, compromise it and wreak havoc on the system's data.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am just wondering how a fork bomb works, I know that there are similar questions but the answers aren't quite what I am looking for (or maybe I just haven't been able to come across one)
How does it work in terms of processes?
Do children keep being produced and then replicating themselves? is the only way to get out of it is by rebooting the system?
Are there any long lasting consequences on the system because of a fork bomb?
Thanks!
How does it work in terms of processes?
It creates so many processes that the system is not able to create any more.
Do children keep being produced and then replicating themselves?
Yes, fork in the name means replication.
is the only way to get out of it is by rebooting the system?
No, it can be stopped by some automated security measures, eg. limiting the number of processes per user.
Are there any long lasting consequences on the system because of a fork bomb?
A fork bomb itself does not change any data but can temporarily (while it runs) cause timeouts, unreachable services or OOM. A well-designed system should handle that but, well, reality may differ.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
What would happen if the Linux kernel deleted itself? Will there be a moment when it could no longer delete files because rm or the program used for deletion has been deleted too?
Regards.
The question is (apart from being off-topic) somewhat wrong in itself, as rm is not part of the kernel, but either a shell built-in or a separate user-level program. Admittedly, rm uses a syscall provided by the kernel, but that is irrelevant.
The kernel itself is loaded from a compressed image and locked in RAM. It does not matter whether you delete the compressed image until you reboot (which will fail with the boot loader giving you a message like "vmlinuz not found"). You have no way of removing the kernel from RAM (well, other than rebooting...).
Also, for the most part, it does not even matter whether you delete a file, including a running program's executable anyway (if we may be so daunting as to call the kernel a "program" for a moment) under Linux, because deleting a file merely removes the link, not the file. It is a Windows-typical assumption that deleting a file does evil, destructive things.
Under Unix-like systems, it is perfectly possible to delete (or replace) a program while it is running, and it will not cause any problems at all. You will remove the name in the filesystem, that's all. Any open descriptors will remain valid until the last one is closed, the original file will stay intact as-is for any observer who obtained a handle earlier, and it will be "gone" for everyone trying to get at it later.