|
The above will work on Solaris, but I have not tried it on Linux. Rather than go to all this hassle of trying to avoid dealing with the SIGCHLD I think the easiest thing is going to be actually handle the signal and call waitpid on the child. Not only will this stop zombies, but its the cleanest and most portable, and you can get all sorts of information back from the child (esp if you use sigaction).
|
|
|
|
|
Thanks, for your advice Johnny buddy!
Thanks, Johnny buddy!
What do you mean "will work"? Do you mean you can not see "defunc" process from "ps -aux"?
I have referenced some materials, and write a sample from your idea, but it does not work. (still can see "defunc" process from "ps -aux")
Source Code:
--------
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
struct sigaction sig;
pid_t pid;
sigemptyset (&sig.sa_mask);
sig.sa_flags = SA_NOCLDSTOP;
sig.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sig, NULL);
//signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
--------
Can you help?
regards,
George
|
|
|
|
|
hi there..
thanks for your time firstly..
i am having a strange problem in the invoke of my IDispatch..
This method is called from the get property of an aX control.
When i call this get method, i dont seem to get any return vaule in the pvarresult variable..
any suggestions..
here is the method:
double CControl:: GetNumber(long nRow, long nCol)
{
DISPPARAMS DispParam1;
EXCEPINFO excep;
UINT nArgErr;
VARIANT pVarResult;
double temp;
DispParam1.cArgs = 2; //number of arguments
DispParam1.cNamedArgs = 0;// Number of named arguments.
DispParam1.rgvarg = new VARIANTARG[2];
DispParam1.rgvarg->vt = VT_ARRAY;
DispParam1.rgvarg[1].vt = VT_I4;
DispParam1.rgvarg[1].lVal = nRow;
DispParam1.rgvarg[0].vt = VT_I4;
DispParam1.rgvarg[0].lVal = nCol;
IImpl::Invoke(DISPID_Number , IID_NULL , 0 , DISPATCH_PROPERTYGET, &DispParam1, &pVarResult , &excep, &nArgErr);
temp = pVarResult.dblVal;
//delete [] DispParam1.rgvarg;
return temp;
}
|
|
|
|
|
try to VariantInit the result variant.
VariantInit( &pVarResult );
this can help (and if not, it's anyway better)
|
|
|
|
|
thanks
kindest regards
|
|
|
|
|
Hello
I'm developing my own controls library and want to implement Office XP menu support, but there is a promblem: I don't know how to calculate appropriate colors. I took a look at ProfUIS, GuiLib, CMenuXP and few other libraries and controls and everybody calculate colors in his own way, but in wrong way. Such applications as SmartFTP, ASP.NET Web Matrix, PHP Expert Editor, etc does the same.
Only one library calculate correct colors. It is Xtreme Toolkit by Codejock Software.
Can anybody help me?
__________________________________________________
Best regards,
v0id
|
|
|
|
|
If the xp colors work and they have no trouble in errors or anything else and are pretty efficient then it really doesn't matter if you use the classes or not. Just first get their permission to use their code and ideas.
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
|
I'm new in the programming for Windows (but have few year expirence in programming for Unix).
My app will be work with unlimit number of grouped object. Each object consists of predefined number of text fields and unlimited number of accociated binary objects.
The database will support only one client/database builder.
I can build the db by simply creating directory structure but is there any solution to do this by using Access datafiles of something like that?
|
|
|
|
|
Have a look a this link [^].
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Mastering MFC Development Using Microsoft Visual C++ 6
Chapter 7: Using OLE DB Templates for Data Access
Chapter 8: Creating ADO Database Applications
M$PRESS
|
|
|
|
|
Hello all,
I'm writing a quick/dirty class wrapper for the Win32 MDI API. After developing most of the code, I came across this article by Jason Henderson, who has done the same thing, and found my code was about 99% identical . I am using the same strategy of calling CreateWindow and passing 'this' in lParam, then using SetWindowLong/GetWindowLong in WndProc to store/retrieve the class pointer in the HWND.
My code successfully creates a Frame, Client, and Child windows. However, for some reason when creating the Child window, the class pointer in lParam gets corrupted when the WndProc tries to retreive it from the CREATESTRUCT. In the debugger lParam is 0x00891030, then in WndProc it retrieves 0x0012fcfc every time.
How can this happen? I'm creating the Frame and Child WndProc's the exact same way, so why would the Child have this problem?
Thanks for reading.
|
|
|
|
|
For the archives, I was able to work around this problem by using the WM_MDICHILD message instead of CreateMDIWindow or CreateWindowEx. I can't explain why it works, but it now works like a charm.
If anyone can shed light, I would appreciate it. One day I may need to use CreateWindowEx because you can run multithreaded MDI children, but you can't with WM_MDICHILD.
|
|
|
|
|
Hello, I'm just a little curious. When i browse through some librarys I sometimes see functions delclared this way:
<returntype> SomeFunc(<arg list>) = 0;
Now my question is: What does the = 0; mean and what is its purpuse?
thanks in advance.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
If it's in a class, you might be referring to a pure virtual declaration
class SomeClass
{
virtual void someFunc() = 0;
};
Which means that there is no body of the function supplied, or in other words, that you need to derive from that class, adding the required functionality.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks, now I can go to sleep without wondering what it might be...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hi guys (sorry for the last incomplete message).
Do you have a fast algorithm to generate the permutations of a string.
Ex:
4-3-2
4-3-2 4-2-3 3-4-2 3-2-4 2-4-3 2-3-4
And another one that ignore repeated chars?
Ex
4-1-1
4-1-1 1-4-1 1-1-4
Actually 4-1-1 had to appear twice but I only want that appears one.
Best Regards
Dr.Pi
|
|
|
|
|
I don't know about the avioding repetitions part, but here is what I would do:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
typedef void (*FOUND)(char*);
void PermRec(char *str, char *buf, FOUND callback)
{
int i, n;
char *buf2;
if (*str == '\0')
{
(*callback)(buf);
return;
}
n = strlen(buf);
buf2 = malloc(n + 2);
for (i = 0; i <= n; i++)
{
if (i != 0) memcpy(buf2, buf, i);
buf2[i] = *str;
if (i != n) memcpy(buf2 + i + 1, buf + i, n - i);
PermRec(str + 1, buf2, callback);
}
free(buf2);
}
void EnumPermutations(char *str, FOUND callback)
{
PermRec(str, "", callback);
}
void foundone(char *str)
{
printf("%s\n", str);
}
int main (int argn, char **argv)
{
if (argn <= 1)
{
printf ("Usage:\n %s <string>\neg:\n %s 123", argv[0], argv[0]);
return 1;
}
EnumPermutations(argv[1], foundone);
} eg if called with "123", first it places the 1:
1
then it places the 2 in each of the 2 spots:
21 or 12
then it places the 3 in each of the 3 spots:
321 or 231 or 213, 312 or 132 or 123
what I would probably then do is make it remember in foundone() which permutations it had already recieved, and ignore them if it gets them again.
BTW: there is a "modify" button for when you mess up your post
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Thanks
I'll try it
Best Regards
Dr.Pi
|
|
|
|
|
try this (not for repeated chars):
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
void swap(char* pc1,char* pc2)
{
char ch;
ch = *pc1;
*pc1 = *pc2;
*pc2 = ch;
}
void perm (char* s,int pos)
{
if (pos == (int)strlen(s))
{
printf("%s\n",s);
return;
}
for (int i=pos;i < (int)strlen(s);i++)
{
swap(s+pos,s+i);
perm(s,pos+1);
swap(s+pos,s+i);
}
}
int main(int argc, char* argv[])
{
char s[] = "abc";
perm(s,0);
return 0;
}
|
|
|
|
|
|
How can I send extended chars (c>=128) using SendInput()?
I have tried sending eg {PRESS ALT}{NUM 0}{NUM 1}{NUM 7}{NUM 5}{RELEASE ALT} to type '¯' - this is you you type it on the keyboard - but it had no effect.
any ideas?
thanks in advance
=====
Phlip
Always proofread carefully to see if you any words out
|
|
|
|
|
Hello, everyone!
Suppose in multi-process environment, one process want to read
characters from stdin, and the other process has nothing to do
with stdin. And there are no synchronize control between the two
process.
And I think it has chances that the characters can be read by the
second process even if the second process has nothing to do with
stdin, and the first process will miss some characters.
Am I correct?
I have seen one solution from others. They use "close (stdin)" in
the socond process. Is this a good solution?
Thanks in advance,
George
|
|
|
|
|
Every process will have its own stdin, so theres no need to worry about synchronisation (unless you are talking about parent/child processes?). Its only when youve got multiple threads in one process trying to use stdin that you will need to think about synchronisation, and then a simple mutex should do the job.
|
|
|
|
|
Thanks, Johnny buddy!
I am talking about parent/child processes. I am currently dealing with
a cross-platform IPC library which acts like "fork" in Linux.
Can you help with my original question?
regards,
George
|
|
|
|
|
Win32 has no parent/child relationship between processes. Johnny's answer is just as valid. Each process has its own stdin.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|