3

Unfortunately I don't have a suspend command (busybox/ash). But I can use kill -STOP $$ to return from a backgrounded shell (sh &) to the parent shell (and fg later).
But instead of typing this long kill-command I would like to write a script (named suspend) which should do this:

#!/busybox sh
kill --STOP $$

But this didn't work. It seems that I open another shell and suspend it simultaneously.

So what is the right suspend-script and how do I call it (exec?)?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
deetee
  • 75
  • 1
  • 7
  • 1
    Great idea. You mean the suspend-script is `kill -STOP $$` only and I call it with `. /sbin/suspend`? I'm gonna try it. – deetee Mar 07 '16 at 14:01
  • 1
    That works in principle. But I have to type `. suspend` (starting with a dot and a blank). Isn't there a solution to type simply `suspend`? – deetee Mar 07 '16 at 14:10
  • 1
    Sorry for my late comments, you are typing faster than I do. Unfortunately I use ash and I don't know if ash supports aliases in .ashrc (?). I'm gonna try but in principle I would like to do it without alias (simply typing a command). – deetee Mar 07 '16 at 14:14

1 Answers1

1

To sum up what I've written in the comments above:

The simplest way get a simple command for what you're trying to do is to make an alias in your ~/.profile according to this website.

echo 'alias suspend=kill --STOP $$' >> ./~profile # Add alias to .profile
source ./~profile # Let ash update its list of aliases

Now you can use a short suspend command.

It might be difficult to do it using a script since a child process cannot easily (or at all) modify the environment of the parent.

beresfordt
  • 5,088
  • 10
  • 35
  • 43
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79