I have trouble with scanf and a loop on linux. If in the shell Linux, if I execute my file like this : Then the result will be this : Here : lol Here : lol Here : lol Here : lol Here : lol Here : lol Here : lol Here : lol Here : lol Here : lol
Tag: c++
C – program is terminated (fork() and exec())
I have the following code: The idea is to call with program with 1 command line argument which is a name of another compiled C program in the same folder. I want to execute that program from within the C code (hence the use of fork()), and at the same time i want to launch another program from within the
Checking if errno != EINTR: what does it mean?
I’ve found this piece of code used several times (also a similar one where it’s used open() instead of write()). Why it is checked if && errno != EINTR here ? Looking for errno on man I found the following text about EINTR, but even if I visited man 7 signal that doesn’t enlighten me. EINTR Interrupted function call (POSIX.1);
How to view the internal data of a smart pointer inside gdb?
I’ve got test program like below: Debug it: It only prints out the pointer type information of si, but how to get the value stored in it (in this case 5)? How can I check the internal content of si during debugging? Answer Try the following: Now, this assumes that you’re using libstdc++.so, given the output for p si. Alternatively,
Debugging a linux daemon process written in C
On occasion a daemon I wrote in C gets these error messages: My question is how can I examine that address in libc-2.19.so to see which function is being called when the error occurs? I tried using gdb but I get : Answer With the data you provide there’s very little that can be done here to make a diagnose
gcc creates mime type application/x-sharedlib instead of application/x-application
Given the following C++ code ‘mini.cpp’: and the compiler command: the result of is How do I get ‘application/x-application’ as a mime type? I’m using gcc 6.2.0 on Kubuntu. Answer gcc doesn’t set the mime type. mimetype guesses the appropriate mime type based on the contents of the file. For ELF files (most compiled binaries and shared libraries), the header
How one can safely serialize std::basic_istream::pos_type?
In one of my projects I have to cache positional information about certain data chunks found in large files. I’ve already implemented a small API built around std::basic_istream<char>::pos_type placed in maps. Now I need to serialize these descriptors into a bytestream and write them on a disk for further usage (on other *nix-machines as well). I have read that this
C: Stop executing and jump to specific point in program on receiving a signal
I have written a code where two independent programs (say 1 & 2) are communicating via message queues. Each programs sends a message of a specific mtype and waits for response of specific mtype. Based on the mtype functions are invoked. program 2 initially waits on select() on the message queue waiting for message chain initiation from program 1 and
Making Directory in C Program [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago. Improve this question For my assignment, I’ve to write a function to create a directory but I’m not allowed to use SYS functions at all! Is there any
What happens after the execution of a handler function on the SIGCHLD signal in C?
I was wondering what exactly happens after the execution of a handler on a signal in C, more specifically on the SIGCHLD signal. I’m actually building a shell and I need to do this: User enters a command with “&” as the last argument A new process is created with fork The parent process returns to the main function and