How can I check to see if a process is stopped from the command-line?
354
Solution 1
You can check whether the process is in stopped state, T
is ps
output.
You can do:
[ "$(ps -o state= -p PID)" = T ] && kill -CONT PID
[ "$(ps -o state= -p PID)" = T ]
tests whether the output ofps -o state= -p PID
isT
, if so sendSIGCONT
to the process. Replace PID with the actual process ID of the process.
Solution 2
Another way would be
pid=1
status=`cat /proc/$pid/wchan`
if [ "$status" == "do_signal_stop" ] ; then
echo "$pid sleeps: $status"
else
echo "$pid does not sleep: $status"
fi
Related videos on Youtube
Author by
Stefan Szakal
Updated on September 18, 2022Comments
-
Stefan Szakal over 1 year
I have the following form model:
public class Form { public string Field1; public string Field2; public Applicant PrimaryApplicant; public Applicant SecondaryApplicant; } public class Applicant { [Required(ErrorMessage = "Please enter a first name"), Display(Name = "First Name")] public string FirstName; [Required(ErrorMessage = "Please enter a last name"), Display(Name = "Last Name")] public string LastName; }
The primary applicant is always required while second applicant is optional, unless any of it's fields is set.
I've tried implementing it using IValidatbleObject interface and Validate method but it doesn't work. (ModelState.IsValid was still returning false)
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { var validationResult = new List<ValidationResult>(); foreach (var property in TypeDescriptor.GetProperties(this).Cast<PropertyDescriptor>()) { Validator.TryValidateValue(property.GetValue(this), validationContext, validationResult, property.Attributes.OfType<ValidationAttribute>()); } var validationCount = TypeDescriptor.GetProperties(this) .Cast<PropertyDescriptor>() .Count(p => p.Attributes.OfType<ValidationAttribute>().Any()); if (!IsPrimaryApplicant && validationResult.Count() == validationCount) validationResult.Clear(); return validationResult; }
How to do validation in this type of scenario?
-
Admin over 7 yearsyou say a program in the title, so you mean the name or you mean the PID like in the example?
-
Admin over 7 yearsDo you want to continue it in the foreground (grabbing the terminal) or in the background?
-