Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
We have frequent computer-lab classes where we need to submit assignments over a local network. We have to submit assignments before the class finishes. The problem is, the destination IP accepts only about 15 maximum connections at a time. Some students like to lobby that for some reason i.e. they keep their conection open and do not allow others to connect.To combat this problem I use a simple batch file as follows:
:1
start/wait \\10.0.120.5\Shared_\Assignments\
goto 1
Although it is rudimentary, it works pretty well for my purposes as it connects to an open spot as soon as it is available. But there are some problems:
If the connection is full, its displays "This computer has reached maximum number of connection" and displays a dialog box. Start/wait being start/wait, naturally waits it out. I'd like for it to skip this and not show me a dialog box if possible.
Right now, If I'm connected, I need to kill the task with taskmanager. I would like this step to be automatic too. Can I have it so that the batch terminates as soon as the connection is made? Previously, I used an anchor-file(a file I put myself in the teacher's IP in a different folder) to check whether or not it was present to have the batch process know that the connection has been made. This is no longer possible as the server has changed to accept only files in certain locations where uploading such anchor-file is not an option. Surely, there must be a more elegant solution to this.
My core question is: Is it possible to utilize all the parameters provided by Start to achieve this? Or do I need a plethora of conditionals?
Here's the pretty obvious solution I was looking for!
Tried in the next Lab Class and it turns out I didn't need to target anchor files after all (Ref: 2nd part of Some Problems here). Sometimes the simple solutions are right there staring back at you.
:1
start/wait \\10.0.120.5\Shared_\
if not exist "\\10.0.120.5\Shared_\" goto 1
exit
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm using a simple pthreads process-shared mutex in a shared memory segment to coordinate multiple server instances.
Code is straightforward:
On startup server attaches to shared memory segment if it exists, or creates it if it doesn't:
shm_open(), mmap(MAP_SHARED) etc.
This works very well while testing, but once deployed after a while i come across cases where server instances don't coordinate at all. I can replicate this by deleting the shared memory segment after a server has started: future servers instances will create/use a new segment but the existing one is stuck with the old segment nobody uses so in effect it's isolated from the rest ...
So my guess is the shared memory segment in /dev/shm is getting deleted somehow, and not by me. This is the only thing that makes sense... What is going on here ??
Running debian with linux 4.9.
Ah, looks like systemd is the culprit:
From dev-shm-files-disappearing:
After hours of searching and reading, I found the culprit. It's a setting for systemd. The /etc/systemd/logind.conf contains default configuration options, with each of them commented out. The RemoveIPC option is set to yes by default. That option tells systemd to clean up interprocess communication (IPC) for "user accounts" who aren't logged in. This does not affect "system accounts"
In my case, the files and directories were being created for a user account, not a system account.
There are two possible solutions:
Create the files with/for a system user -- a user created with the system option (adduser -r or adduser --system)
Edit /etc/systemd/logind.conf, uncomment the line RemoveIPC=yes, change it to RemoveIPC=no, save, and reboot the system
In my case, I went with option #2 because the user was already created.
See also this post on postgresql mailing list.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm trying to get file-locking semantics on Linux that are close to what Windows offers for the purpose of not deleting cache files while they're open by a separate process. My program creates various temporary cache files that I want to delete when it closes, however multiple instances might run at the same time and I don't want to delete a file that's in use by another instance, because it will break semantics - the cache file is opened by name at various points and if deleted, that will break. I know that Linux won't physically delete the file until all open handles are closed, but I still need to open it by name.
The name of each file uniquely identifies the contents, i.e. I know that if I need data X, it's in the cache file named hash(X), so it doesn't matter if the current instance is the one creating it, or if I'm reusing a file created by another instance. Obviously it's not exactly the hash of the data, since if I had the data, I wouldn't need cache files, but suffice to say that reusing cache files is what I want.
My problem is that I haven't found a race-free way to lock the file with flock after opening it. Between those two calls another process might finish and run a cache cleanup operation that deletes the file I've just created. I don't need mandatory locking like on Windows, since it's only my program accessing those files, but I do need a way to keep instances from stepping on each other.
Edit: I'm using C.
I don't want to delete a file that's in use by another instance
You cannot delete a file used by another process (or even the same process). You can delete the directory entry (or rather a directiry entry, as there may be more than one) that points to that file, but the file itself will remain live for as long as it's kept open by any process. Files in Linux are reference-counted, that's what making it work.
An easy method to collaboratively "lock" a file by name would be this:
char new_filename[FILENAME_SIZE] = "busy_";
link (filename, strcat(new_filename, filename));
fd = open(new_filename, "r");
if (fd) {
......
close (fd);
}
unlink (new_filename);
One does not check the result of link. If everyone does this to open a file, and cleanup only unlinks the original name, you are set.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
The vx570 has a USB port that I know you can use as a software download vector, but when I tried it, I was unable to initiate the download process. There is nothing in system mode that would allow me to to execute a program like DDL, which we use for serial (RS232) downloads. What do I need to do to initiate the download and how do I specify where the files should go?
Yes, this is actually pretty simple.
1) Create a folder for each file group you want to put data in. So if you want to put something into RAM in file group 3, then name the folder 3. If you want to put something into FLASH in file group 3, then name it F3. You can mix at match at will so if you are going to load your program in to file group 3 and it has both RAM and FLASH components, then you would have a 3 folder AND an F3 folder. If you were also loading VMAC, then you would ALSO have a 1, F1, 15 and F15.
2) Package all this stuff up into a .zip file. You MUST name it Verifone.zip Put this file onto your USB thumb drive at the root level.
3) Go into system mode and press '#' to start a full download into group 1.
4) Insert the thumb drive into the USB slot on the 570. The terminal will see that there is a file called Verifone.zip and will guide you through the rest.
There is one potentially tricky thing about all of this and that is the config.sys variables. Since you aren't using DDL.exe, you don't have a way to set them during the download. You CAN, however, load the config.sys file directly to the terminal as part of the download. The problem is that it is a compressed format file, so if you were to look at it in notepad, it would contain a bunch of junk like äåöíáîæéì. The only way I know of to generate this file is to use the "Direct Upload Utility" as found on VeriFone's DevNet site. As it turns out, it will also do the rest of step 1 (above) for you, as well.
1) Download DUL from DevNet onto your computer
2) Using DDL.exe (or whatever you have been using to set up terminals in the past), configure a terminal to be in the exact state that you want your future downloads to be in.
3) Connect the terminal to your computer and run DUL. Use the * wildcard to specify that you want all files to upload to your computer. See DUL's documentation for more details.
4) Optional: DUL's naming convention is to prefix RAM folders with I and use 2 digit group numbers. I suspect this will work, but I always change mine to single digits and drop the I for RAM groups.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
One of the drivers I'm developing has caused a BSOD. Unfortunately a dump file was not created since it was not configured / low resources. I was trying to reproduce this crash but no luck so far.
Is there any way to get some info using WinDbg or any other tool?
I have this information:
A screenshot of the BSOD
The .sys file.
Its pdb
The source code
The machine it was crashed on
I have everything except the dump itself.
Your help will be much appreciated.
As I said above, no dump (/minidump) exists. This is the actual problem.
For this specific crash, I know I won't be able to get the stack. Just getting the specific line of code will be good enough. Because the BSOD contains the module's address, it seems like there should be a way to detect which line exactly is it. As I mentioned above, I do have the .sys file, the pdb and the source code.
This is the specific code taken from MSDN: SYSTEM_SERVICE_EXCEPTION.
How can I know from there what was the specific line? and/or the specific exception raised?
You have the crash address, want to know the source line?
Fire up kd or windbg, disasm that address and code before it. Find the function entry point (where it adjust the stack) and you can now lookup the symbol table. From there you disasm again and compare the source.
Sorry, I guess you need to read some asm. I know no better way.
If you are lucky you will have minidump in C:\windows, so check if its there.
If its available open it in Windbg and analyse.
You don't need to configure for low resource to create dump, refer this link http://support.microsoft.com/kb/254649 on how to setup windows to create dump files. Create full dump if you want to debug your driver.
Coming back to your question to analyse issue:
Refer bugcheck reference here to understand your BSOD error. http://msdn.microsoft.com/en-us/library/windows/hardware/hh406232(v=vs.85).aspx
Depending upon what BSOD you got, check any parameters or other information to get possible cause.
But its not likely that you will reach to good conclusion with information you have. You will need dump file to really understand the issue.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to add command line interface support to a server program.
So each time I want to check server's status, I can telnet to the server's control port,
and input command to check the server's status.
Is there any open source library implements such functionality so I need not write it from scratch?
Further more, if the library can provides more features such like cisco's command line interface (tab key hint, command query, vi mode, or even symbol based command), that's would be great.
libcli sounds like exactly the thing you are looking for. It includes Cisco-like functionality and a telnet server. I've never used it, but came across it a while back when I was looking for a similar CLI.
A telnet server is almost trivial to write from scratch, the only thing easier is the obsolete rlogin protocol, which is still accessible from ssh. You won't have any trouble making a few socket calls to implement such a thing.
You are about to be told, I am sure, not to use telnet but rather ssh. It's good advice, but you have two good choices here: implement telnet in open code locally and connect via an ssh tunnel, or, use an ssh server to log in via a secure channel.
See here: for SSH servers. That won't help you directly, although apache has a Java implementation that embeds easily. If you just google for "telnet server" you will get more links than I can possibly quote here, in a variety of languages, many containing example code for an easy implementation. It's also possible that the Stevens books treat this topic directly as well.
If you don't want to deal with sockets or shared memory segments, its rather easy to have your daemon update a SQLite3 database so that a client can get its stats with a simple query, however that can become problematic as you'd need to use the host OS's user/group management to grant underprivileged users access.
In all reality, its usually better to just use a simple socket connection. In Linux, its quite easy to figure out (locally) what user ID is calling and permit only a few.
You can use the socket library to listen to a TCP port, receive commands there and output back your status. There's not much code required to do that; an example can be found here: http://www.paulgriffiths.net/program/c/echoserv.php.
(The example program just returns the command that has been sent; clearly, you would want to replace Writeline(...); with something more specific to your application.)
Is readline(3) what you are looking for?
readline will read a line from the terminal and return it, using prompt as a prompt. If
prompt is NULL or the empty string, no prompt is issued. The line returned is allocated
with malloc(3); the caller must free it when finished. The line returned has the final new‐
line removed, so only the text of the line remains.
It was unclear from the question if you are looking to implement the connection of the user interaction. This answers, the UI part.
This is the software I used before. It provides almost the same CLI features with Cisco CLI interface.
All you need to do is porting the source code under lib folder.
Quagga Routing Suite
https://www.nongnu.org/quagga/