shc icon indicating copy to clipboard operation
shc copied to clipboard

Pipes instead of command line and random locks

Open fabio-brugnara opened this issue 2 years ago • 5 comments

Hi all, I suggest a solution (at least in my experience), for a couple of questions appearing among the Issues.

  1. Remove the limitations of command line length limits and exposability by using pipes instead of command line to pass the script to the interpreter. A -P option is added to enable this.
  2. Remove occasional locks introduced by a race condition in the untraceable() function: the possibility that the CONT signal arrives before the process has actually entered the stopped state, being therefore discarded.
  3. Add support for python script.

Sorry, I'm not familiar with the mechanism of pull request and so on, but all the stuff is simple enough to be manageable by a simple:

patch shc.c shc.patch

againt the current master branch, where shc.patch is extracted from: shcpatch.zip

A drawback of the "pipe" feature, is the fact that the script may lose the possibility to retrieve the original name by accessing $0, $ARGV[0] or sys.argv[0] (depending on the language). Often this can be worked around referring to the $_ environment variable, but not always. In exchange for this annoyance, the limit on the script size and the possibility of seeing the source in clear with ps or /proc/*/cmdline both disappear.

The patch has been applied to the "original" v3, and has been working reliably for years under linux. Only recently I discovered this git repo with the updated version.

fabio-brugnara avatar Jun 01 '23 13:06 fabio-brugnara

The patch has been applied to the "original" v3,

could you please provide a link

neurobin avatar Jun 01 '23 13:06 neurobin

Hi neurobin, I mean the one found in Francisco Rosales' page. I applied those modifications years ago to that source file, and used afterwards. But the patch file I sent is to be applied to the current master version of this git.

fabio-brugnara avatar Jun 01 '23 16:06 fabio-brugnara

Sorry, I'm not familiar with the mechanism of pull request

you just need to fork this repository, then apply your patches, then push. After that you can go to https://github.com/neurobin/shc/pulls to create a PR.

neurobin avatar Jun 02 '23 08:06 neurobin

Done. I hope it will be useful.

fabio-brugnara avatar Jun 02 '23 19:06 fabio-brugnara

Just find out I implemented almost the same idea as this solution, except the anoymous pipe / fifo difference. https://github.com/liberize/ssc

liberize avatar Jan 19 '24 15:01 liberize