C :: Program To Check For Running Pid Using System Call In UNIX / Linux

Dec 11, 2013

I have written a program which uses a pid to check if the process is currently running and return a value based on the system call result.But the program core dumps

Code:

#include <stdio.h>
#include <string.h
int main( argc, argv )
int argc;
char * argv[];
{
int p_pid = 99;
char buff[1000];
}

[code]....

What is the mistake in this code and is it portable in both unix/linux , is the method secure (grepping for program name )?

View 6 Replies


ADVERTISEMENT

C :: Gzip System Linux - Program To Unite 2 Commands Into 1 Command

Sep 15, 2013

I'm writing a program to turn the two commands "gunzip file.tar.gz" then "tar -xvf file.tar" into "x file.tar.gz", but I've ran into a problem I can't find a solution to, here are the outputs I get depending on if I use a gunzip -f flag in my system() call or not:

if I use: (void)system("gunzip ", store );
> x file.tar.gz
gzip: compressed data not read from a terminal. Use -f to force decompression.
type: gzip -h
store 1: file.tar.gz
tar: option requires an argument -- 'f'

[code]....

I don't know if the problem is something to do with my code or something to do with gunzip and if it is to do with gunzip if I can even solve it with my code? I've tried for a while to find more info and read the gunzip man file, ran "gunzip file.tar.gz" outside of my program and found that it works normally producing file.tar so I suspect the problem is related to system()?

View 3 Replies View Related

C/C++ :: Check Printing Program Breaks Halfway Through Running

Apr 3, 2015

For my c++ we're suppose to write a program that prints out a check. It's suppose to translate the numeric value of the dollars to worded strings.

Header File:

#ifndef CHECKWRITING_H
#define CHECKWRITING_H
#include <string>

[Code]....

View 1 Replies View Related

C++ :: Call A Program By System

Apr 17, 2013

So I know that I can call a program by system("prog.exe"), but what do I add in when I want to pass a parameter?

View 2 Replies View Related

C/C++ :: System Call A Command From Within A Program?

Sep 17, 2014

how to invoke a UNIX command within a program

I found this:

dd if=/dev/urandom of=myrandom bs=100 count=1

and I found this:

dd if=/dev/zero of=mytestfile.out bs=1 count=0 seek=1G

I want to call this command, by using the command line and typing Generate or something to that effect.

Basically, I want to be able to build random size files, content isn't important to me at this time.

View 8 Replies View Related

C :: System Call To Pause Execution Of Program For Few Seconds

Feb 2, 2014

I know there has to be a system call to pause (not system("pause") execution of a program for a few seconds. I would like to give the illusion that my program is 'thinking' rather than just spit out the result as soon as the user has hit the enter key.

View 5 Replies View Related

C :: Sending Simulated Keyboard Input Into Running System Application

Nov 26, 2014

I'm trying to simulate a ctrl+ keypress into a running application.

Code:
#include <stdio.h>
int main (void) {
system("/usr/local/bin/rundb");
}

My problem is that the rundb program needs the user to type ctrl-b then s to actually start executing. What is the best way to handle this automatically? Some sort of fork/pipe?

View 3 Replies View Related

C :: Program That Does UNIX Strings

Jun 4, 2014

I am not a programmer, C-wise. Mainly a shell scripter. any C program that I can use that can work like UNIX strings | grep "pattern"...At the moment, on a binary file, I am using UNIX strings and then grep for a pattern and print out that line and does some awk -F":" thing. This is manageable for when the binary file is 50M but not for where files are 100M and above. I mean it still works but takes longer since strings work on the entire file.

Basically the information that I am trying to extract from the binary file is some type of header that is contained in a file. I am thinking of maybe writing a 'simple' C program that will read the first few bytes of the binary file and then print the line that contains the string that I am looking for. I don't believe the header is at the end of the file but more in the beginning. I am wanting to extract the header information to be able to rename or make a copy of the binary in a more user-friendly name.

Any good reference/link to a sample program on reading a binary file maybe. Main reason why I am wanting a C program is because the binary file can be on Windows or *nix.

View 2 Replies View Related

Visual C++ :: Check Whether Application Instance Is Running Or Not

Jan 20, 2014

For my project I need to check whether my application instance is already running or not. I got the following code from Net ..

Code :

HANDLE mutex;
mutex = CreateMutex( NULL, TRUE, _T("MYAPPNAME"));
if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
// There's another instance running. What do you do?
AfxMessageBox(_T("Application Already Exists"));
PostQuitMessage(0);
ExitThread(0);
return;
}

The code works fine .. but the code even works fine , even if I pass any string as a parameter to CreateMutex. E.g.

mutex = CreateMutex( NULL, TRUE, _T("QQQQ"));

How it is working fine ?

View 5 Replies View Related

C :: Assign System Call To Variable

Feb 22, 2014

I have to ask system (linux) for a value and then assign it to the variable.

Example:

unsigned char date[] = system("date");

Of course this is wrong, but illustrated what is my goal.

How to achieve this effect ? I've heard about POSIX but how to include and use it.

View 10 Replies View Related

C :: System Call For A Pause Function

Jan 20, 2014

I know there has to be a system call for a pause function. I simply want the program to pause for a few seconds before executing the next line of code. I do NOT want the user to enter a keypress, just pause the output or code execution for a few seconds.

system (pause); waits for keypress right? I just want it to wait 3 seconds before proceeding. I know it should take an argument for milliseconds right? Also, this is for a homework assignment I have already completed, just doll'in it up a bit for extra credit...maybe...

View 7 Replies View Related

C/C++ :: Booking System - Comparing 2 Char Variables In Check Function

Aug 31, 2014

I had problem in comparing 2 char vairable in check function

if(room_no==r)

variable r take input from user and compare to room_no read from file.

#include<iostream>
#include<conio.h>
#include<fstream>
#include<stdio.h>
#include<dos.h>
#include<string>
#include<stdlib.h>

[Code] .....

View 2 Replies View Related

C :: Program That Lets To Download Torrents On Linux

Mar 22, 2013

I want to create a program that lets you download torrents on linux ... how to start ...

View 1 Replies View Related

C :: Program To Recognize Pattern Of Signals (linux Environment)

Mar 6, 2015

I need to write a c program that can receive signals and recognize a certain pattern (SIGUSR1, SIGUSR2, SIGUSR1, SIGUSR2). once the pattern is caught the program terminates itself.

I am able to send the signals to the program from a different process, but I am unsure on how to get the signal handler to recognize the pattern. here is what i have so far:

Code:
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
sig_atomic_t sigusr1_count = 0;
sig_atomic_t sigusr2_count = 0;

[Code] .....

I just need getting the program to be able to catch that specific pattern.

View 4 Replies View Related

C++ :: Program To Search Index File Using Command Line In Linux

Oct 28, 2014

I have code that creates an index file created from a data file of records.

#include <iostream>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
class Record {

[Code]...

I now need to write a second program that allows the user to enter a command on the Linux command line such as

search 12382 prog5.idx

and returns the information for the record with that key. The code I included for the index file is correct and works properly, but how to write the second program.

Here is the index file created by the first program:

8: blank 0 $ 0.00
12165: Item16 30 $ 7.69
12345: Item06 45 $ 14.20
12382: Item09 62 $ 41.37
12434: Item04 21 $ 17.30
16541: Item12 21 $ 9.99
21212: Itme31 19 $ 8.35
34186: Item25 18 $ 17.75
41742: Item14 55 $ 12.36

The top line is a dummy record, the first number is the size of the file.

View 19 Replies View Related

C++ :: Running A Program Outside IDE

Jul 23, 2014

after you have compiled a program can you run it without an IDE?

View 17 Replies View Related

C++ :: Checking If A Program Is Running?

Jun 17, 2014

I have a question, how can I check if a program is running using c++? For example

if (notepad.exe is running) {
.... ..... ....

View 3 Replies View Related

C++ :: Running A SLR Parser Program?

Apr 27, 2012

I need to run a program that makes a SLR Parser Table.

Here is the code :

Code to find first and follow:

saved as SLR.h
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#define epsilon '^'

since I didn't know how to type epsilon symbol temporarily I am using ^

char prod[20][20],T[20],NT[20],c[10][10],foll[10][10],fir[10][10];
int tt,tnt,tp,a;
int follow[20][20],first[20][20];
void first_of(char);
int count(int j);
void rhs(int j);

[code]....

View 3 Replies View Related

C :: Queue Program Not Running After Pressing 1

Apr 20, 2013

Code:

#include<stdio.h>
#include<process.h>
struct que

[Code].....

View 1 Replies View Related

C/C++ :: Program Is Running But It Won't Stop Compiling

Nov 20, 2014

#include <iostream>
using namespace std;
int main() {

[Code].....

View 2 Replies View Related

Visual C++ :: Running GUI Program In Background?

Apr 22, 2013

i created a windows service that will run another program. but the program i want to run has a gui and i don't want the gui to be visible, i just want the program to run in the background.

But i have to do it without editing the gui program

here's my code:

Code:
TCHAR* path = L"C:Myfile est.exe";
STARTUPINFO info = {0};
PROCESS_INFORMATION processInfo;
ZeroMemory( &info, sizeof(info) );
info.cb = sizeof(info);

[code]....

i tested this code with notepad and it runs notepad in the background without displaying the window but when i try run my program it doesn't work. i don't know why its works for one program and not the other..

View 14 Replies View Related

C++ :: Dynamically Resizing Array While Program Is Running?

Feb 4, 2015

I'm working the 4th problem in chapter 14 of the Jumping into C++ book. In the book, he gives an example program for dynamically resizing an array while the program is running. It works fine for integer types but i need to do the same with a string type array. Right now my program is crashing because the string array is not resizing itself. Here's the part of the code im trying to figure out. The part for the int array has been ignored using // since it works fine and I'm trying to figure out whats wrong with the string array.

Code:
#include <iostream>
#include <string>
//Write a program that lets users keep track of the last time they talked to each of their friends.
//Users should be able to add new friends (as many as they want!) and store the number of days ago

[Code]......

View 8 Replies View Related

C :: Program Compiles Fine But Seg Faults While Running

Dec 1, 2013

So i compile fine, but when i run my program, after the printf it just segfaults (core dumped)...

Code:
#include<stdio.h>#include<string.h>
#include<stdlib.h>
void main() {
unsigned int j=0, max=9;
char num[100] , str1[100], str2[max];
FILE *fp;

[Code] .....

View 4 Replies View Related

C :: Simple File And String Program Not Running

Mar 6, 2015

The assignment is to write a program that statistically computes similarity of C syntax with another program; a same and a different. The one used here is in C language, it's called Battleship.cpp. The program must open a file and read line by line for keywords and then produce statistics. The reason my code is not running is the fopen function is failing and it goes to return -1. I am using MS Visual Studio 2013 and there are no compiler errors after turning off deprecation. I do see, however, this error UMEngx86.dll'. Cannot find or open the PDB file. The file being opened is in my source folder.

Code:
1
2
3
4
5
[code]....

View 4 Replies View Related

C++ :: Setting Background Color And Running A Program

Feb 1, 2013

I use turbo c++ 3.0

How to set the background color using the function setbkcolor() in graphics.h

will i need to run the exe file in full screen if i use this function?

View 4 Replies View Related

C/C++ :: Full Menu Not Shown When Running Program

Mar 4, 2014

The program is not showing my full menu just the 0 Exit and the last line of text. This is the full main source file (not implementation file or header file).

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
struct menuItem{
string itemDesc;
double price;
int menuType;

[Code] .....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved