--fork option does not execute post receive command -xcs
Moderator: Moderator Team
--fork option does not execute post receive command -xcs
Hi OFFIS Team!
After receiving a study, the command specified with the -xcs option will not be executed after the specified timeout -tos when the --fork option is given.
Example:
bin/storescp --fork -od /project/gateway/images/TELERAD_IN -dhl -ss study -xcs ./studycomplete.pl TELERAD_IN #p #a #c -rns -tos 30 50082
When I start the same program without the --fork option, the command will be executed.
It seems the the --fork option doesn't trigger the -xcs event.
Thank you very much in advance for your help!
Alfred
After receiving a study, the command specified with the -xcs option will not be executed after the specified timeout -tos when the --fork option is given.
Example:
bin/storescp --fork -od /project/gateway/images/TELERAD_IN -dhl -ss study -xcs ./studycomplete.pl TELERAD_IN #p #a #c -rns -tos 30 50082
When I start the same program without the --fork option, the command will be executed.
It seems the the --fork option doesn't trigger the -xcs event.
Thank you very much in advance for your help!
Alfred
RE: --fork option does not execute post receive command -xcs
Hi Alfred, Hallo Offis Team,
I made one small modification to storescp.cc to
fix this problem ...
Here is a diff of my modified storescp.cc and storescp.cc_ORIG:
Gerhard
I made one small modification to storescp.cc to
fix this problem ...
Here is a diff of my modified storescp.cc and storescp.cc_ORIG:
Code: Select all
pl@lirdiag1:~/work/dicomtests/dcmtk-3.5.4/dcmnet/apps> diff storescp.cc storescp.cc_ORIG
1116,1127c1116
< if (DUL_processIsForkedChild())
< {
< // HG 2006.02.28 aber: wenn end of study timeout aktiviert ist ...
< if( opt_endOfStudyTimeout != -1 && ! lastStudyInstanceUID.empty() )
< {
< if (opt_verbose) printf("HG: wait for endOfStudyTimeout in child ...\n");
< }
< else
< {
< break;
< }
< }
---
> if (DUL_processIsForkedChild()) break;
Hi!
Using this code the fork option works under most circumstances. But there is a problem when a clients connects to storescp when storescp is in the timeout loop waiting for the end-of-study timeout. While this time no further connections are possible.
Any suggestions?
Thanks a lot in advance!
Alfred
Using this code the fork option works under most circumstances. But there is a problem when a clients connects to storescp when storescp is in the timeout loop waiting for the end-of-study timeout. While this time no further connections are possible.
Any suggestions?
Thanks a lot in advance!
Alfred
RE: --fork option does not execute post receive command -xcs
Hi Alfred, Hallo Offis Team,
after some more modifications to storescp.cc (from dcmtk-3.5.4),
the --eostudy-timeout
and the different --exec-on-... Options
work with --fork, too.
Additionally I implemented two new features:
- a new parameter #r to pass the "remote_host" of an Association
to the different --exec-on Scripts,
- a new --exec-on-sostudy (-xss) Switch (=StartOfStudy),
to execute a Script after receiving the first Object of a NEW Study
WARNING!
- this modified version will compile ONLY on linux,
cause i have no time / environment to check this with Windows.
You can find my modified storescp.cc here:
http://earchive.at/dcmtk-3.5.4
(all modifications are marked with: // HG: ... )
Gerhard
after some more modifications to storescp.cc (from dcmtk-3.5.4),
the --eostudy-timeout
and the different --exec-on-... Options
work with --fork, too.
Additionally I implemented two new features:
- a new parameter #r to pass the "remote_host" of an Association
to the different --exec-on Scripts,
- a new --exec-on-sostudy (-xss) Switch (=StartOfStudy),
to execute a Script after receiving the first Object of a NEW Study
WARNING!
- this modified version will compile ONLY on linux,
cause i have no time / environment to check this with Windows.
You can find my modified storescp.cc here:
http://earchive.at/dcmtk-3.5.4
(all modifications are marked with: // HG: ... )
Gerhard
Last edited by gerhardh on Thu, 2006-06-01, 12:10, edited 2 times in total.
-
- OFFIS DICOM Team
- Posts: 1444
- Joined: Tue, 2004-11-02, 17:22
- Location: Oldenburg, Germany
- Contact:
It was not to hard to adjust Gerhard's code to make it work under Windows (just use findfirst/findnext/findclose instead of opendir / closedir)
But then another issue arises. Using the next commandline is OK:
storescp --fork -xcr dosomething.bat 1000
To give the batch-file some parameters you can add for example #f and/or #p as follows
storescp --fork -xcr "dosomething.bat #p #f" 1000
The quotation marks are needed, else you'll get the error message "Too many parameters". The problem is that for the child process the quotation marks are lost. This results in the same error message if you start to send a DICOM-file.
So I changed dul.cxx a little. I "replaced" lines 1651 and 1652 with the following:
Now all parameters have quotation marks (but this is no problem, at least under Windows).
Luuk
But then another issue arises. Using the next commandline is OK:
storescp --fork -xcr dosomething.bat 1000
To give the batch-file some parameters you can add for example #f and/or #p as follows
storescp --fork -xcr "dosomething.bat #p #f" 1000
The quotation marks are needed, else you'll get the error message "Too many parameters". The problem is that for the child process the quotation marks are lost. This results in the same error message if you start to send a DICOM-file.
So I changed dul.cxx a little. I "replaced" lines 1651 and 1652 with the following:
Code: Select all
cmdLine += " \"";
cmdLine += command_argv[i];
cmdLine += "\"";
Luuk
Luuk, thanks for the idea on the fix. I'm uneasy with quoting every argument, plus it makes enclosed escaped quotes behave different with/without the --fork option. The below code does the following.
1. Fixes the CreateProcess() security hole when the first argument is NULL as described at MSDN. http://msdn.microsoft.com/library/defau ... rocess.asp
2. If the argument contains a space, enclose it in quotes, and escape all sub-quotes. This should restrict adding quotes and escaping to only arguments which need it. Detecting/Re-escaping other characters might be advantageous as well.
3. If the argument does not contain a space, process like 3.5.4 (no escaping or quoting).
dul.cxx Line ~1649
1. Fixes the CreateProcess() security hole when the first argument is NULL as described at MSDN. http://msdn.microsoft.com/library/defau ... rocess.asp
2. If the argument contains a space, enclose it in quotes, and escape all sub-quotes. This should restrict adding quotes and escaping to only arguments which need it. Detecting/Re-escaping other characters might be advantageous as well.
3. If the argument does not contain a space, process like 3.5.4 (no escaping or quoting).
dul.cxx Line ~1649
Code: Select all
// prepare the command line
OFString cmdLine;
OFString cmdLineTemp; // (rhinojunk) used to rebuild escaped quotes.
size_t position; // (rhinojunk) used to rebuild escaped quotes.
// (rhinojunk) Add quotes around storescp path per CreateProcess()
// (rhinojunk) security notes on MSDN.
cmdLine = "\"";
cmdLine += command_argv[0];
cmdLine += "\"";
cmdLine += " --forked-child";
for (int i=1; i < command_argc; ++i)
{
// (rhinojunk) If command_argv[i] contains a space, escape
// (rhinojunk) enclosed double quotes and enclose in new quotes
// (rhinojunk) for proper processing by child.
OFString cmdLineTemp = command_argv[i];
if (cmdLineTemp.find(" ", 0) != OFString_npos)
{
position = 0;
while ((position = cmdLineTemp.find("\"",position)) != OFString_npos)
{
cmdLineTemp.insert(position, "\\");
position = position + 2; // (rhinojunk) need to account for insert.
}
cmdLine += " \"";
cmdLine += cmdLineTemp;
cmdLine += "\"";
}
else // (rhinojunk) no spaces found, do normal append.
{
cmdLine += " ";
cmdLine += command_argv[i];
}
}
Re: --fork option does not execute post receive command -xcs
It seems these fixes never made it into the 3.6.0 release. Is there any plan to merge these changes?
Thanks!
Thanks!
-
- DCMTK Developer
- Posts: 2503
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: --fork option does not execute post receive command -xcs
As far as I remember, the "space quoting" thing has been fixed already. See this patch. Or, do you mean something else?
Btw, I personally do not like the whole Windows multi-process stuff (aka "fork") in the DCMTK. To me it looks like a bad hack ...
Btw, I personally do not like the whole Windows multi-process stuff (aka "fork") in the DCMTK. To me it looks like a bad hack ...
-
- Posts: 3
- Joined: Thu, 2019-01-10, 15:10
Re: --fork option does not execute post receive command -xcs
What ever came from this?
The latest version, 3.6.4, still does not support `--exec-on-eostudy` and `--fork` simultaneously.
Basically, what are people using as the solution to receive from multiple sources at once, and know when receiving is completed?
I may be misunderstanding the benefit / need of `--fork` altogether.
(I've been "away" from the dcmtk community for about 5 years now, so there are a lot of things I'm catching up on)
The latest version, 3.6.4, still does not support `--exec-on-eostudy` and `--fork` simultaneously.
Basically, what are people using as the solution to receive from multiple sources at once, and know when receiving is completed?
I may be misunderstanding the benefit / need of `--fork` altogether.
(I've been "away" from the dcmtk community for about 5 years now, so there are a lot of things I'm catching up on)
-
- DCMTK Developer
- Posts: 2503
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: --fork option does not execute post receive command -xcs
Nowadays, one would probably use the DcmStorageSCP class and extend it for handling multiple associations at a time (e.g. based on the thread-pool SCP class). The corresponding command line tool would then be "dcmrecv"...
PS: Welcome back!
PS: Welcome back!
Who is online
Users browsing this forum: Baidu [Spider] and 1 guest