I am trying to accept user input of yes or no to a question and depending on the answer read back the value of my variable. I can never get commands attached to variables to work or my if statements to accept yes or no. It just keeps going to “not a valid answer”. Please let me know how to
Tag: conditional-statements
How does pthread_cond_wait (conditon variable) unblock all threads only once, not multiple times?
I have successfully implemented a producer thread and 2 worker threads or consumer threads. The producer thread broadcasts condition using pthread_cond_broadcast. And the worker threads are blocked by pthread_cond_wait. The code looks something likes this: Thread 1 (Producer Thread): Thread 2 (Worker/Consumer Thread): Thread 3 (Worker/Consumer Thread): My question is why does Thread 2 or Thread 3 does not re-execute
Do we need to unlocking a mutex after recived a signal from cond variable?
I making an app in C for educational purposes with mutexes and conditional variables. Short example here: Can you explain me, why after “while” statment (and recived signal from second thread) we need to unlock the mutex, when signal makes that mutex is locked? I get it from a lot examples from web, but when i want to work with
bash: string value based entries filtering
I have this check in my script: It is writing lines that contain contact* from one file to an array. How can I add another check that will skip the xi* values in that line and write it in the array? I tried something like: But it is not working for me. :/ Answer The first file looks like this:
Copy first N files which start with ‘a’ ‘c’ or ‘e’ from one folder to another in Linux
I have many files in specified directory. For instance, I want to copy 6 of them to one location. I came up with this: The problem is that every file which starts with ‘a’ ‘c’ ‘e’ is copied. There should be first 6 files, but I receive 8 (4 with ‘a’, 3 with ‘c’ and 1 with ‘e’). I was
bash process monitor script echo empty when no process found
I’ve created a process monitor to check for the presence of a running process, and if found we need to check its parent to determine if it is acceptable or not, it’s a security check basically. It works great when I look for running processes and gives me output that I expect. However, for some reason when no process is
Check if a condition is false
It is seems to be an easy question, I wonder why googling didn’t give anything helpful — nor in StackOverflow, nor in tutorials. I just need to check using bash that a condition is false. Of what I found I tried and none of them print Hello. I found only two similar questions, but the end answer in both cases