mount fails from spawned process

RoeeK

I want to start a process that uses a USB hard drive once it gets inserted.
Since UDEV rules specifically mentions not to run long-time processes from RUN command, I send a FIFO message to my service which then opens the relevant process.

So the flow goes like this:
UDEV > runs action process > sends FIFO message to service > service gets message > runs the process who works with the HDD (aka HDD-PROCESS).

If I run my service from shell-1 and run 'action process' (the one that UDEV runs) from shell-2 everything works (including when trying it with udev).
But in deployment, the service is spawned from init, and when it does, the mount command fails saying "No such device".

I then detached "HDD-PROCESS" with fork and setsid, but that didn't help either.

from inittab:

::respawn:/opt/spwn_frm_init

ps relevant output:

PID    PPID  PGID  SID  COMM             ARGS
31112     1 31112 31112 spwn_frm_init    /bin/sh /opt/spwn_frm_init
31113 31112 31112 31112 runSvc           /bin/sh /app/sys/runSvc
31114 31113 31112 31112 python           python /app/sys/mainSvc.py
24064     1 24064 24064 python           /usr/bin/python /app/sys/hdd_proc.py sdb1
  • everything runs under root (ps shows that too, I omitted that to save screen space).

So in short: when I run /opt/spwn_frm_init from shell, everything works. when I kill it and let it re-spawn from inittab, it doesn't and mount fails with error above.

UPDATE:
There is no problem when trying to mount an ext3 drive, but only on the NTFS one (using ntfs-3g).

RoeeK

Found it!
One of the differences between spawned process and another one who runs from shell is the environment variables which usually should be a problem when all I want is to call mount.
But when I noticed the problem happens only with the NTFS drive, it suddenly occurred to me that mount might need to call ntfs-3g so it worth checking if the second is accessible in the PATH variable.

which ntfs-3g led to /usr/local/bin/ntfs-3g which was mentioned in the default shell PATH but not in the one spawned from init.

To solve it, I added this /usr/local/bin to PATH in the "HDD-PROCESS" and mount began to work :)

A better error message in mount could have saved a lot of time here...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Testing captured IO from a spawned process

From Dev

Not receiving stdout from nodejs spawned process

From Dev

Node Kue and Child Process - get error from spawned process

From Dev

Unable to pipe to or from spawned child process more than once

From Dev

Using a timer changes the error message received from an exiting spawned process

From Dev

why there is not output from spawned process show using escript

From Dev

Closing pipe does not interrupt read() in child process spawned from thread

From Dev

Get process ids of all spawned processes from xargs

From Dev

Spawned process from java inherits parent socket on FreeBSD

From Dev

How to monitor process spawned using launchUriAsync from WinJs

From Dev

Expect: How to get the exit code from spawned process

From Dev

Interaction with spawned process in Scala

From Dev

CreateMutex() fails with ERROR_ACCESS_DENIED when called by process spawned by Windows Service

From Dev

Supervisord error "child process was not spawned"

From Dev

Killing a process spawned by another thread

From Dev

killing the master process spawned by an at command

From Dev

Unable to get output from infinitely running Ruby application spawned from Node child process

From Dev

How can a process be blocking another process (that it spawned)?

From Dev

How do I preserve colors in the console when running a script from a spawned child process?

From Dev

Sending an Error Object from a spawned child-process over an IPC-channel

From Dev

How to kill all child processes spawned by a process started from a script on kill or kill -9

From Dev

Is it possible to modify source binary in linux if any process spawned from that binary is still running?

From Dev

Mount from rc.local fails; how to do it properly?

From Dev

ionic 2 start fails with error with the spawned command

From Dev

os.kill not working on spawned process

From Dev

spawned process in node.js exiting immediately

From Dev

How to detect if a Node spawned process is still running?

From Dev

Visual Studio Code - Debugging a spawned process

From Dev

Read stdout of spawned process that is waiting for input

Related Related

  1. 1

    Testing captured IO from a spawned process

  2. 2

    Not receiving stdout from nodejs spawned process

  3. 3

    Node Kue and Child Process - get error from spawned process

  4. 4

    Unable to pipe to or from spawned child process more than once

  5. 5

    Using a timer changes the error message received from an exiting spawned process

  6. 6

    why there is not output from spawned process show using escript

  7. 7

    Closing pipe does not interrupt read() in child process spawned from thread

  8. 8

    Get process ids of all spawned processes from xargs

  9. 9

    Spawned process from java inherits parent socket on FreeBSD

  10. 10

    How to monitor process spawned using launchUriAsync from WinJs

  11. 11

    Expect: How to get the exit code from spawned process

  12. 12

    Interaction with spawned process in Scala

  13. 13

    CreateMutex() fails with ERROR_ACCESS_DENIED when called by process spawned by Windows Service

  14. 14

    Supervisord error "child process was not spawned"

  15. 15

    Killing a process spawned by another thread

  16. 16

    killing the master process spawned by an at command

  17. 17

    Unable to get output from infinitely running Ruby application spawned from Node child process

  18. 18

    How can a process be blocking another process (that it spawned)?

  19. 19

    How do I preserve colors in the console when running a script from a spawned child process?

  20. 20

    Sending an Error Object from a spawned child-process over an IPC-channel

  21. 21

    How to kill all child processes spawned by a process started from a script on kill or kill -9

  22. 22

    Is it possible to modify source binary in linux if any process spawned from that binary is still running?

  23. 23

    Mount from rc.local fails; how to do it properly?

  24. 24

    ionic 2 start fails with error with the spawned command

  25. 25

    os.kill not working on spawned process

  26. 26

    spawned process in node.js exiting immediately

  27. 27

    How to detect if a Node spawned process is still running?

  28. 28

    Visual Studio Code - Debugging a spawned process

  29. 29

    Read stdout of spawned process that is waiting for input

HotTag

Archive